| [6f646d] | 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 |  | 
|---|
| [57f243] | 11 | #include "LinearAlgebra/Space.hpp" | 
|---|
| [6f646d] | 12 |  | 
|---|
| [e0ba10] | 13 | #include <iosfwd> | 
|---|
| [6f646d] | 14 | #include <memory> | 
|---|
| [45ef76] | 15 | #include <vector> | 
|---|
| [6f646d] | 16 |  | 
|---|
|  | 17 | class Vector; | 
|---|
| [5589858] | 18 | class Plane; | 
|---|
| [6256f5] | 19 | class LinePoint; | 
|---|
| [6f646d] | 20 |  | 
|---|
|  | 21 | class Line : public Space | 
|---|
|  | 22 | { | 
|---|
| [82cf79] | 23 | friend bool operator==(const Line&,const Line&); | 
|---|
| [6256f5] | 24 | friend class LinePoint; | 
|---|
| [6f646d] | 25 | public: | 
|---|
| [45ef76] | 26 | Line(const Vector &_origin, const Vector &_direction); | 
|---|
|  | 27 | Line(const Line& _src); | 
|---|
| [6f646d] | 28 | virtual ~Line(); | 
|---|
|  | 29 |  | 
|---|
| [41da13] | 30 | Line &operator=(const Line& rhs); | 
|---|
|  | 31 |  | 
|---|
| [45ef76] | 32 | virtual double distance(const Vector &point) const; | 
|---|
|  | 33 | virtual Vector getClosestPoint(const Vector &point) const; | 
|---|
|  | 34 |  | 
|---|
|  | 35 | Vector getDirection() const; | 
|---|
|  | 36 | Vector getOrigin() const; | 
|---|
|  | 37 |  | 
|---|
|  | 38 | std::vector<Vector> getPointsOnLine() const; | 
|---|
|  | 39 |  | 
|---|
|  | 40 | Vector getIntersection(const Line& otherLine) const; | 
|---|
| [6f646d] | 41 |  | 
|---|
| [42a101] | 42 | Vector rotateVector(const Vector &rhs, double alpha) const; | 
|---|
| [b59648] | 43 | Line rotateLine(const Line &rhs, double alpha) const; | 
|---|
| [69baa4] | 44 | Plane rotatePlane(const Plane &rhs, double alpha) const; | 
|---|
| [42a101] | 45 |  | 
|---|
| [5589858] | 46 | Plane getOrthogonalPlane(const Vector &origin) const; | 
|---|
|  | 47 |  | 
|---|
| [f932b7] | 48 | std::vector<Vector> getSphereIntersections() const; | 
|---|
|  | 49 |  | 
|---|
| [6256f5] | 50 | LinePoint getLinePoint(const Vector&) const; | 
|---|
|  | 51 | LinePoint posEndpoint() const; | 
|---|
|  | 52 | LinePoint negEndpoint() const; | 
|---|
|  | 53 |  | 
|---|
| [b59648] | 54 |  | 
|---|
|  | 55 |  | 
|---|
| [6f646d] | 56 | private: | 
|---|
|  | 57 | std::auto_ptr<Vector> origin; | 
|---|
|  | 58 | std::auto_ptr<Vector> direction; | 
|---|
|  | 59 | }; | 
|---|
|  | 60 |  | 
|---|
| [82cf79] | 61 | bool operator==(const Line&,const Line&); | 
|---|
|  | 62 |  | 
|---|
| [e0ba10] | 63 | std::ostream & operator << (std::ostream& ost, const Line &m); | 
|---|
|  | 64 |  | 
|---|
| [45ef76] | 65 | /** | 
|---|
|  | 66 | * Named constructor to make a line through two points | 
|---|
|  | 67 | */ | 
|---|
|  | 68 | Line makeLineThrough(const Vector &x1, const Vector &x2); | 
|---|
|  | 69 |  | 
|---|
| [6256f5] | 70 | /** | 
|---|
|  | 71 | * Class for representing points on a line | 
|---|
|  | 72 | * These objects allow comparison of points on the same line as well as specifying the | 
|---|
|  | 73 | * infinite "endpoints" of a line. | 
|---|
|  | 74 | */ | 
|---|
|  | 75 | class LinePoint{ | 
|---|
|  | 76 | friend class Line; | 
|---|
|  | 77 | friend bool operator==(const LinePoint&, const LinePoint&); | 
|---|
|  | 78 | friend bool operator<(const LinePoint&, const LinePoint&); | 
|---|
|  | 79 | public: | 
|---|
|  | 80 | LinePoint(const LinePoint&); | 
|---|
|  | 81 | LinePoint& operator=(const LinePoint&); | 
|---|
|  | 82 | Vector getPoint() const; | 
|---|
|  | 83 | Line getLine() const; | 
|---|
|  | 84 | bool isInfinite() const; | 
|---|
|  | 85 | bool isPosInfinity() const; | 
|---|
|  | 86 | bool isNegInfinity() const; | 
|---|
|  | 87 |  | 
|---|
|  | 88 | private: | 
|---|
|  | 89 | LinePoint(const Line&,double); | 
|---|
|  | 90 | Line line; | 
|---|
|  | 91 | double param; | 
|---|
|  | 92 | }; | 
|---|
|  | 93 |  | 
|---|
|  | 94 | bool operator==(const LinePoint&, const LinePoint&); | 
|---|
|  | 95 | bool operator<(const LinePoint&, const LinePoint&); | 
|---|
|  | 96 |  | 
|---|
|  | 97 | inline bool operator!= (const LinePoint& x, const LinePoint& y) { return !(x==y); } | 
|---|
|  | 98 | inline bool operator>  (const LinePoint& x, const LinePoint& y) { return y<x; } | 
|---|
|  | 99 | inline bool operator<= (const LinePoint& x, const LinePoint& y) { return !(y<x); } | 
|---|
|  | 100 | inline bool operator>= (const LinePoint& x, const LinePoint& y) { return !(x<y); } | 
|---|
|  | 101 |  | 
|---|
|  | 102 |  | 
|---|
| [6f646d] | 103 | #endif /* LINE_HPP_ */ | 
|---|