mt
 All Classes Files Functions Enumerations Groups Pages
Classes | Public Member Functions | List of all members
mt::Plane3 Class Reference

Three-dimensional plane class. More...

#include <plane3.h>

Classes

class  BadPlane
 Ill-defined plane exception. More...

Public Member Functions

 Plane3 ()
 Plane3 (const Unit3 &norm, const Scalar &dist, const DirectionType &type=DIRECTED)
 Constructor for unit normal vector and distance to the origin input.
 Plane3 (const Vector3 &norm, const Scalar &dist, const DirectionType &type=DIRECTED)
 Plane3 (const Unit3 &norm, const Point3 &sup, const DirectionType &type=DIRECTED)
 Constructor for unit normal vector and support point input.
 Plane3 (const Vector3 &norm, const Point3 &sup, const DirectionType &type=DIRECTED)
 Constructor for non-unit normal vector and support point input.
 Plane3 (const Point3 &sup1, const Point3 &sup2, const Point3 &sup3, const DirectionType &type=UNDIRECTED)
 Constructor for three support points.
bool operator== (const Plane3 &P) const
bool operator!= (const Plane3 &P) const
Point3 project (const Point3 &p) const
 Projects point p on current plane.
Scalar distance (const Point3 &p) const
 Unsigned distance from point p to current plane.
Unit3 getNormal () const
 Gets plane normal unit vector.
Unit3getNormalRef ()
const Unit3getNormalRef () const
Scalar getDistOrig () const
Scalar & getDistOrigRef ()
const Scalar & getDistOrigRef () const
Point3 getSupport () const
DirectionType getDirectionType () const
 Gets plane direction type.
DirectionType & getDirectionTypeRef ()
const DirectionType & getDirectionTypeRef () const
Unit3 getSupportVector () const
Plane3 getParallelPlane (const Scalar &d) const
 Returns a plane parallel to the current plane separated by d.
void setNormal (const Unit3 &norm)
 Sets plane normal unit vector.
void setDistOrig (const Scalar &dist)
 Sets signed distance from the plane to the coordinate system origin.
void setSupport (const Point3 &sup)
 Sets plane support point.
void setDirectionType (const DirectionType &type)
 Sets plane direction type.
void setValue (const Unit3 &norm, const Scalar &dist, const DirectionType &type=DIRECTED)
 Sets plane with normal, distance to origin, and direction type.
void setValue (const Unit3 &norm, const Point3 &sup, const DirectionType &type=DIRECTED)
 Sets plane with normal, support point, and direction type.
void setValue (const Point3 &sup1, const Point3 &sup2, const Point3 &sup3, const DirectionType &type=DIRECTED)
 Sets plane with three support points.

Detailed Description

Three-dimensional plane class.

Planes are represented using the Hessian normal form

\[ \hat{\mathbf{n}} \mathbf{x} + d = 0 \]

where

Additionally, a plane can be considered to be directed or undirected. If two directed planes differ only in that their normal vectors are antiparallel, they are considered different. If at least one of the planes is undirected, then they are considered to be equal. If left unspecified in the constructor, all planes are considered directed except for planes constructed from three support points (see example below)

After a plane is constructed, it is tested to ensure it was well defined. For example, after constructing a plane with a normal vector and support point inputs, the support point is tested to ensure it is contained in the plane. Another case that can yield an ill-defined situation is a plane constructed with three almost-collinear points.

This is an example of how to use the Plane3 class:

using namespace mt;
// Some necessary geometric elements
Scalar d = -2.0;
Unit3 nor(1.0, 0.0, 0.0);
Point3 p1(2.0, 0.0, 0.0);
Point3 p2(2.0, 1.0, 0.0);
Point3 p3(2.0, 0.0, 1.0);
Point3 p4(2.0, 0.0, 2.0);
// Plane constructors
Plane3 P1;
Plane3 P2(nor, d);
Plane3 P3(nor, p1, Plane3::DIRECTED);
Plane3 P4 = -P2;
Plane3 P5(-nor, d, Plane3::UNDIRECTED);
Plane3 P6(p1, p2, p3);
Plane3 P7(p1, p3, p4); // oops!
// Planes P2 and P3 are exactly the same, although they were constructed
// with different input values. For example, cout << P2 will produce:
// normal: [1 0 0] dist. to origin: -2 (directed)
bool test;
test = (P2 == P3); // test = true
// Plane P4 differs from planes P2-P3 in that its normal vector is inverted.
// Since these planes are directed, they are not considered equal.
test = (P2 == P4); // test = false
test = (P3 == P4); // test = false
// Like P4, plane P5 has an inverted normal vector but it is also
// undirected, so equality tests with the above planes will return true.
test = (P2 == P5); // test = true
test = (P4 == P5); // test = true
// The normal chosen for plane P6 depends on the values of the input
// support points. For this reason, the constructor for three points sets
// the direction type to \a undirected by default.
// Plane P7 cannot be constructed since the supplied support points are
// collinear, and a mt::BadPlane exception is thrown.

Constructor & Destructor Documentation

mt::Plane3::Plane3 ( )
inline

Default constructor. Creates a directed plane coincident with the xy plane.

mt::Plane3::Plane3 ( const Vector3 norm,
const Scalar &  dist,
const DirectionType &  type = DIRECTED 
)
inline

Constructor for non-unit normal vector and distance to the origin input.

Member Function Documentation

Scalar mt::Plane3::getDistOrig ( ) const
inline

Gets signed distance from the plane to the coordinate system origin. The sign of this distance is determined by the direction of the plane normal $ \hat{\mathbf{n}} $

Point3 mt::Plane3::getSupport ( ) const
inline

Gets plane support point that is closest to the coordinate system origin.

Unit3 mt::Plane3::getSupportVector ( ) const
inline

Gets a unit vector perpendicular to the plane normal.

If the coordinate system axis closest to the plane normal is x, the return vector will point in the direction of the y axis projected on the plane. Otherwise it will point in the direction of the y axis projected on the plane.


The documentation for this class was generated from the following file: