ML Reference
ml::Plane Class Reference

Class defining a plane in 3D. More...

#include <mlPlane.h>

Public Member Functions

 Plane ()
 Constructor. Normal defaults to (0,0,1) and distance to 0.
 
 Plane (const Vector3 &normal, MLdouble distance)
 Constructs a plane from normal normal and distance from origin distance.
 
 Plane (const Vector3 &p0, const Vector3 &p1, const Vector3 &p2)
 Constructs a plane from three points in space.
 
 Plane (const Vector3 &normal, const Vector3 &point)
 Constructs a plane from normal and point in space.
 
Vector3 getClosestPoint (const Vector3 &point) const
 Projects a point onto this plane.
 
bool intersect (const Line &l, Vector3 &intersection) const
 Intersects this plane with line l and returns the intersection point in intersection.
 
bool isInHalfSpace (const Vector3 &point) const
 Returns whether the point lies in the half-space of the plane into which the normal of the plane points (which is equal to getDistance(point) >= 0.0)
 
MLdouble getDistance (const Vector3 &point) const
 Returns the distance of point from plane.
 
const Vector3getNormal () const
 Returns the plane normal.
 
bool setNormal (const Vector3 &n)
 Sets the plane normal to n (performing normalization), or (1,0,0) if n == 0.
 
void setDistance (double d)
 Sets the distance from origin to d.
 
MLdouble getDistanceFromOrigin () const
 Returns the minimum distance of plane from origin.
 
MLSign edgeIntersect (const Vector3 &v1, const Vector3 &v2, Vector3 &intersectPos) const
 Determines whether an edge (line segment) bounded by v1 -> v2 intersects *this.
 

Detailed Description

Class defining a plane in 3D.

Definition at line 29 of file mlPlane.h.

Constructor & Destructor Documentation

◆ Plane() [1/4]

ml::Plane::Plane ( )

Constructor. Normal defaults to (0,0,1) and distance to 0.

◆ Plane() [2/4]

ml::Plane::Plane ( const Vector3 & normal,
MLdouble distance )

Constructs a plane from normal normal and distance from origin distance.

It is up to the caller to avoid degenerated plane settings.

◆ Plane() [3/4]

ml::Plane::Plane ( const Vector3 & p0,
const Vector3 & p1,
const Vector3 & p2 )

Constructs a plane from three points in space.

It is up to the caller to avoid degenerated plane settings.

◆ Plane() [4/4]

ml::Plane::Plane ( const Vector3 & normal,
const Vector3 & point )

Constructs a plane from normal and point in space.

It is up to the caller to avoid degenerated plane settings.

Member Function Documentation

◆ edgeIntersect()

MLSign ml::Plane::edgeIntersect ( const Vector3 & v1,
const Vector3 & v2,
Vector3 & intersectPos ) const

Determines whether an edge (line segment) bounded by v1 -> v2 intersects *this.

If there's an intersection, the sign of v1, NEGATIVE or POSITIVE, w.r.t. the plane is returned with the intersection intersect updated. Otherwise ZERO is returned and intersectPos is left unchanged.

◆ getClosestPoint()

Vector3 ml::Plane::getClosestPoint ( const Vector3 & point) const

Projects a point onto this plane.

◆ getDistance()

MLdouble ml::Plane::getDistance ( const Vector3 & point) const

Returns the distance of point from plane.

◆ getDistanceFromOrigin()

MLdouble ml::Plane::getDistanceFromOrigin ( ) const
inline

Returns the minimum distance of plane from origin.

Definition at line 74 of file mlPlane.h.

◆ getNormal()

const Vector3 & ml::Plane::getNormal ( ) const

Returns the plane normal.

◆ intersect()

bool ml::Plane::intersect ( const Line & l,
Vector3 & intersection ) const

Intersects this plane with line l and returns the intersection point in intersection.

Return whether the line is not parallel to plane.

◆ isInHalfSpace()

bool ml::Plane::isInHalfSpace ( const Vector3 & point) const

Returns whether the point lies in the half-space of the plane into which the normal of the plane points (which is equal to getDistance(point) >= 0.0)

◆ setDistance()

void ml::Plane::setDistance ( double d)

Sets the distance from origin to d.

◆ setNormal()

bool ml::Plane::setNormal ( const Vector3 & n)

Sets the plane normal to n (performing normalization), or (1,0,0) if n == 0.

Returns whether n != 0.


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