| 1 | /*
|
|---|
| 2 | * Plane.hpp
|
|---|
| 3 | *
|
|---|
| 4 | * Created on: Apr 7, 2010
|
|---|
| 5 | * Author: crueger
|
|---|
| 6 | */
|
|---|
| 7 |
|
|---|
| 8 | #ifndef PLANE_HPP_
|
|---|
| 9 | #define PLANE_HPP_
|
|---|
| 10 |
|
|---|
| 11 | // include config.h
|
|---|
| 12 | #ifdef HAVE_CONFIG_H
|
|---|
| 13 | #include <config.h>
|
|---|
| 14 | #endif
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 | #include <memory>
|
|---|
| 18 | #include <vector>
|
|---|
| 19 | #include <iosfwd>
|
|---|
| 20 |
|
|---|
| 21 | #include "LinearAlgebra/Exceptions.hpp"
|
|---|
| 22 | #include "LinearAlgebra/Space.hpp"
|
|---|
| 23 | #include "Exceptions/LinearDependenceException.hpp"
|
|---|
| 24 |
|
|---|
| 25 | class Vector;
|
|---|
| 26 | class Line;
|
|---|
| 27 |
|
|---|
| 28 | class Plane : public Space
|
|---|
| 29 | {
|
|---|
| 30 | friend bool operator==(const Plane&,const Plane&);
|
|---|
| 31 | typedef std::auto_ptr<Vector> vec_ptr;
|
|---|
| 32 | public:
|
|---|
| 33 | Plane(const Vector &y1, const Vector &y2, const Vector &y3) throw(LinearDependenceException);
|
|---|
| 34 | Plane(const Vector &y1, const Vector &y2, double _offset) throw(ZeroVectorException,LinearDependenceException);
|
|---|
| 35 | Plane(const Vector &_normalVector, double _offset) throw(ZeroVectorException);
|
|---|
| 36 | Plane(const Vector &_normalVector, const Vector &_offsetVector) throw(ZeroVectorException);
|
|---|
| 37 | Plane(const Plane& plane);
|
|---|
| 38 | virtual ~Plane();
|
|---|
| 39 |
|
|---|
| 40 | Plane &operator=(const Plane&);
|
|---|
| 41 |
|
|---|
| 42 | // Accessor Functions
|
|---|
| 43 | /**
|
|---|
| 44 | * returns normal Vector for a plane
|
|---|
| 45 | */
|
|---|
| 46 | Vector getNormal() const;
|
|---|
| 47 | /**
|
|---|
| 48 | * returns the distance of the plane from the origin
|
|---|
| 49 | */
|
|---|
| 50 | double getOffset() const;
|
|---|
| 51 | /**
|
|---|
| 52 | * returns a vector that points on the plane.
|
|---|
| 53 | * Same as getOffset()*getNormal();
|
|---|
| 54 | */
|
|---|
| 55 | Vector getOffsetVector() const;
|
|---|
| 56 |
|
|---|
| 57 | /**
|
|---|
| 58 | * returns three seperate points on this plane
|
|---|
| 59 | */
|
|---|
| 60 | std::vector<Vector> getPointsOnPlane() const;
|
|---|
| 61 |
|
|---|
| 62 | // some calculations
|
|---|
| 63 | Vector GetIntersection(const Line &Line) const;
|
|---|
| 64 |
|
|---|
| 65 | Vector mirrorVector(const Vector &rhs) const;
|
|---|
| 66 |
|
|---|
| 67 | /**
|
|---|
| 68 | * get a Line that is orthogonal to this plane, going through a chosen
|
|---|
| 69 | * point.
|
|---|
| 70 | *
|
|---|
| 71 | * The point does not have to lie on the plane itself.
|
|---|
| 72 | */
|
|---|
| 73 | Line getOrthogonalLine(const Vector &origin) const;
|
|---|
| 74 |
|
|---|
| 75 | /**
|
|---|
| 76 | * Test if two points are on the same side of the plane
|
|---|
| 77 | */
|
|---|
| 78 | bool onSameSide(const Vector&,const Vector&) const;
|
|---|
| 79 |
|
|---|
| 80 | /****** Methods inherited from Space ***********/
|
|---|
| 81 |
|
|---|
| 82 | virtual double distance(const Vector &point) const;
|
|---|
| 83 | virtual Vector getClosestPoint(const Vector &point) const;
|
|---|
| 84 |
|
|---|
| 85 | private:
|
|---|
| 86 | vec_ptr normalVector;
|
|---|
| 87 | double offset;
|
|---|
| 88 | };
|
|---|
| 89 |
|
|---|
| 90 | bool operator==(const Plane&,const Plane&);
|
|---|
| 91 |
|
|---|
| 92 | std::ostream &operator<< (std::ostream &ost,const Plane& p);
|
|---|
| 93 |
|
|---|
| 94 | #endif /* PLANE_HPP_ */
|
|---|