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