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