cee::Plane Class Reference

Class defining a plane in space. More...

Public Member Functions

 Plane ()
 Constructs a plane. More...
 
 Plane (const Plane &other)
 Constructs a plane as a copy of other. More...
 
 Plane (double A, double B, double C, double D)
 Constructs a plane based on the equation: Ax + By + Cz + Dx = 0. More...
 
Planeoperator= (const Plane &other)
 Assigns other to this plane and returns a reference to this plane. More...
 
bool operator== (const Plane &rhs) const
 Returns true if rhs is equal to this plane; otherwise returns false. More...
 
bool operator!= (const Plane &rhs) const
 Returns true if rhs is NOT equal to this plane; otherwise returns false. More...
 
double A () const
 Returns the value A. More...
 
double B () const
 Returns the value B. More...
 
double C () const
 Returns the value C. More...
 
double D () const
 Returns the value D. More...
 
bool isValid () const
 Returns true if the plane is valid, otherwise returns false. More...
 
double distance (const Vec3d &point) const
 Returns the distance between the give point and this plane. More...
 
double distanceSquared (const Vec3d &point) const
 Returns the square of the distance from the point to the plane. More...
 
Vec3d normal () const
 Returns the normal to this plane. More...
 
Vec3d pointInPlane () const
 Gets a point located on the plane. More...
 
void set (double A, double B, double C, double D)
 Sets A, B, C and D values for this plane. More...
 
bool setFromPointAndNormal (const Vec3d &point, const Vec3d &normal)
 Sets the plane from a point and a normal. More...
 
bool setFromPoints (const Vec3d &p1, const Vec3d &p2, const Vec3d &p3)
 Sets the plane from three points. More...
 
void transform (const Mat4d &matrix)
 Transforms the plane with the given homogeneous transformation matrix. More...
 
bool rayIntersect (const Ray &ray, Vec3d *intersectionPoint) const
 Calculates the intersection point between a ray and the plane. More...
 
bool rayIntersect (const Ray &ray, double *distance) const
 Calculates the distance between a ray and the plane. More...
 
bool projectVector (const Vec3d &vector, Vec3d *projectedVector) const
 Projects the given vector onto the plane. More...
 
Vec3d projectPoint (const Vec3d &point) const
 Projects the given point onto the plane. More...
 

Static Public Member Functions

static Plane createFromPointAndNormal (const Vec3d &point, const Vec3d &normal)
 Returns a plane created from a point and a normal. More...
 
static Plane createFromPoints (const Vec3d &p1, const Vec3d &p2, const Vec3d &p3)
 Returns a plane created from three points. More...
 

Detailed Description

Class defining a plane in space.

The class describes a plane by the equation: Ax + By + Cz + Dx = 0 The plane's normal is defined by the coefficients [A, B, C]

Constructor & Destructor Documentation

cee::Plane::Plane ( )

Constructs a plane.

cee::Plane::Plane ( const Plane other)

Constructs a plane as a copy of other.

cee::Plane::Plane ( double  A,
double  B,
double  C,
double  D 
)

Constructs a plane based on the equation: Ax + By + Cz + Dx = 0.

Member Function Documentation

double cee::Plane::A ( ) const

Returns the value A.

Plane equation: Ax + By + Cz + Dx = 0

double cee::Plane::B ( ) const

Returns the value B.

Plane equation: Ax + By + Cz + Dx = 0

double cee::Plane::C ( ) const

Returns the value C.

Plane equation: Ax + By + Cz + Dx = 0

Plane cee::Plane::createFromPointAndNormal ( const Vec3d point,
const Vec3d normal 
)
static

Returns a plane created from a point and a normal.

Plane cee::Plane::createFromPoints ( const Vec3d p1,
const Vec3d p2,
const Vec3d p3 
)
static

Returns a plane created from three points.

The three points cannot be on a line as they need to define a plane. So (p2 - p1)*(p3 - p1) != 0

double cee::Plane::D ( ) const

Returns the value D.

Plane equation: Ax + By + Cz + Dx = 0

double cee::Plane::distance ( const Vec3d point) const

Returns the distance between the give point and this plane.

double cee::Plane::distanceSquared ( const Vec3d point) const

Returns the square of the distance from the point to the plane.

The square of the distance is relatively fast to compute (no sqrt) and is useful for determine which side the point is on. To obtain the actual distance, divide by sqrt(A^2 + B^2 + C^2) or use the distance() function directly.

bool cee::Plane::isValid ( ) const

Returns true if the plane is valid, otherwise returns false.

cee::Vec3d cee::Plane::normal ( ) const

Returns the normal to this plane.

bool cee::Plane::operator!= ( const Plane rhs) const

Returns true if rhs is NOT equal to this plane; otherwise returns false.

Plane & cee::Plane::operator= ( const Plane other)

Assigns other to this plane and returns a reference to this plane.

bool cee::Plane::operator== ( const Plane rhs) const

Returns true if rhs is equal to this plane; otherwise returns false.

cee::Vec3d cee::Plane::pointInPlane ( ) const

Gets a point located on the plane.

Vec3d cee::Plane::projectPoint ( const Vec3d point) const

Projects the given point onto the plane.

bool cee::Plane::projectVector ( const Vec3d vector,
Vec3d projectedVector 
) const

Projects the given vector onto the plane.

Returns true if successfully projected. false if the given vector is parallel with the plane's normal

bool cee::Plane::rayIntersect ( const Ray ray,
cee::Vec3d intersectionPoint 
) const

Calculates the intersection point between a ray and the plane.

Returns true if an intersection point was found

bool cee::Plane::rayIntersect ( const Ray ray,
double *  distance 
) const

Calculates the distance between a ray and the plane.

Returns true if an intersection point was found

void cee::Plane::set ( double  A,
double  B,
double  C,
double  D 
)

Sets A, B, C and D values for this plane.

Plane equation: Ax + By + Cz + Dx = 0

bool cee::Plane::setFromPointAndNormal ( const Vec3d point,
const Vec3d normal 
)

Sets the plane from a point and a normal.

bool cee::Plane::setFromPoints ( const Vec3d p1,
const Vec3d p2,
const Vec3d p3 
)

Sets the plane from three points.

The three points cannot be on a line as they need to define a plane. So (p2 - p1)*(p3 - p1) != 0

void cee::Plane::transform ( const Mat4d matrix)

Transforms the plane with the given homogeneous transformation matrix.