1 | /*
|
---|
2 | * Line.hpp
|
---|
3 | *
|
---|
4 | * Created on: Apr 30, 2010
|
---|
5 | * Author: crueger
|
---|
6 | */
|
---|
7 |
|
---|
8 | #ifndef LINE_HPP_
|
---|
9 | #define LINE_HPP_
|
---|
10 |
|
---|
11 | // include config.h
|
---|
12 | #ifdef HAVE_CONFIG_H
|
---|
13 | #include <config.h>
|
---|
14 | #endif
|
---|
15 |
|
---|
16 |
|
---|
17 | #include "Space.hpp"
|
---|
18 |
|
---|
19 | #include <iosfwd>
|
---|
20 | #include <memory>
|
---|
21 | #include <vector>
|
---|
22 |
|
---|
23 | class Vector;
|
---|
24 | class Plane;
|
---|
25 | class LinePoint;
|
---|
26 | class RealSpaceMatrix;
|
---|
27 |
|
---|
28 | /** This class represents a line in space stretching to infinity.
|
---|
29 | *
|
---|
30 | * It is defined by its origin and a direction.
|
---|
31 | *
|
---|
32 | * \sa LinePoint and LineSegment
|
---|
33 | */
|
---|
34 | class Line : public Space
|
---|
35 | {
|
---|
36 | friend bool operator==(const Line&,const Line&);
|
---|
37 | friend class LinePoint;
|
---|
38 | public:
|
---|
39 | Line(const Vector &_origin, const Vector &_direction);
|
---|
40 | Line(const Line& _src);
|
---|
41 | virtual ~Line();
|
---|
42 |
|
---|
43 | Line &operator=(const Line& rhs);
|
---|
44 |
|
---|
45 | virtual double distance(const Vector &point) const;
|
---|
46 | virtual Vector getClosestPoint(const Vector &point) const;
|
---|
47 |
|
---|
48 | Vector getDirection() const;
|
---|
49 | Vector getOrigin() const;
|
---|
50 |
|
---|
51 | std::vector<Vector> getPointsOnLine() const;
|
---|
52 |
|
---|
53 | Vector getIntersection(const Line& otherLine) const;
|
---|
54 |
|
---|
55 | Vector rotateVector(const Vector &rhs, double alpha) const;
|
---|
56 | Line rotateLine(const Line &rhs, double alpha) const;
|
---|
57 | Plane rotatePlane(const Plane &rhs, double alpha) const;
|
---|
58 | RealSpaceMatrix getRotationMatrix(double alpha) const;
|
---|
59 |
|
---|
60 | Plane getOrthogonalPlane(const Vector &origin) const;
|
---|
61 |
|
---|
62 | std::vector<Vector> getSphereIntersections() const;
|
---|
63 |
|
---|
64 | LinePoint getLinePoint(const Vector&) const;
|
---|
65 | LinePoint posEndpoint() const;
|
---|
66 | LinePoint negEndpoint() const;
|
---|
67 |
|
---|
68 |
|
---|
69 |
|
---|
70 | private:
|
---|
71 | std::auto_ptr<Vector> origin;
|
---|
72 | std::auto_ptr<Vector> direction;
|
---|
73 | };
|
---|
74 |
|
---|
75 | bool operator==(const Line&,const Line&);
|
---|
76 |
|
---|
77 | std::ostream & operator << (std::ostream& ost, const Line &m);
|
---|
78 |
|
---|
79 | /**
|
---|
80 | * Named constructor to make a line through two points
|
---|
81 | */
|
---|
82 | Line makeLineThrough(const Vector &x1, const Vector &x2);
|
---|
83 |
|
---|
84 | #endif /* LINE_HPP_ */
|
---|