Ocular Engine
Ocular::Math::Plane Class Reference

#include <Plane.hpp>

Public Member Functions

 Plane (Vector3f const &point, Vector3f const &normal)
 
 Plane (Point3f const &a, Point3f const &b, Point3f const &c)
 
void setPoint (Vector3f const &point)
 
void setNormal (Vector3f const &normal)
 
Vector3f const & getPoint () const
 
Vector3f const & getNormal () const
 
float getSignedDistance (Vector3f const &point) const
 
Vector3f getClosest (Vector3f const &point) const
 
void normalize ()
 
Plane getNormalized () const
 
bool intersects (Ray const &ray) const
 
bool intersects (Ray const &ray, Vector3f &point, float &distance) const
 
bool intersects (BoundsSphere const &bounds, IntersectionType *result=nullptr) const
 
bool intersects (BoundsAABB const &bounds, IntersectionType *result=nullptr) const
 
bool intersects (BoundsOBB const &bounds, IntersectionType *result=nullptr) const
 

Static Public Member Functions

static Vector3f GetIntersectionPoint (Plane const &a, Plane const &b, Plane const &c)
 

Detailed Description

An infinite 3D plane represented in point-normal form.

Constructor & Destructor Documentation

Ocular::Math::Plane::Plane ( Vector3f const &  point,
Vector3f const &  normal 
)

Creates a new plane from the given point and normal.

Parameters
[in]pointA point on the plane to intersect with.
[in]normalThe direction of the plane.
Ocular::Math::Plane::Plane ( Point3f const &  a,
Point3f const &  b,
Point3f const &  c 
)

Creates a new plane from three points.

The given points must all lie on the plane and be given in a counter-clockwise order.

The point of the plane is set to 'b'.
The normal is set to (b - a) x (c - a) normalized.

Parameters
[in]aThe first point on the plane
[in]bThe second point on the plane
[in]cThe third point on the plane

Member Function Documentation

Vector3f Ocular::Math::Plane::getClosest ( Vector3f const &  point) const

Calculates the point on the plane that is closest to the specified point.

Parameters
[in]point
Returns
Closest point on plane.
Vector3f Ocular::Math::Plane::GetIntersectionPoint ( Plane const &  a,
Plane const &  b,
Plane const &  c 
)
static

Calculates and returns the point at which three planes intersect.

Parameters
[in]a
[in]b
[in]c
Vector3f const & Ocular::Math::Plane::getNormal ( ) const
Returns
Normalized direction of the plane.
Vector3f const & Ocular::Math::Plane::getPoint ( ) const
Returns
Point that the plane intersects with.
float Ocular::Math::Plane::getSignedDistance ( Vector3f const &  point) const

Calculates the signed distance from the point to the plane.

The result is positive if the point is outside of the plane (in plane's positive half-space i.e. direction of normal).
The result is negative if the point is inside of the plane.
The result is 0 if the point is on the plane.

Parameters
[in]point
Returns
Signed distance to the plane.
bool Ocular::Math::Plane::intersects ( Ray const &  ray) const

Performs an intersection test on a ray and plane.

Note that this operation is actually a line-plane intersection. The line begins at ray origin and extends RAY_LINE_LENGTH.

Parameters
[in])
Returns
TRUE if the ray and plane intersect.
bool Ocular::Math::Plane::intersects ( Ray const &  ray,
Vector3f point,
float &  distance 
) const

Performs an intersection test on a ray and plane.

Note that this operation is actually a line-plane intersection. The line begins at ray origin and extends RAY_LINE_LENGTH.

Parameters
[in]ray
[out]pointThe point that the ray and AABB intersect, if they intersect.
[out]distanceThe distance from the ray origin to the point of intersection
Returns
TRUE if the ray and plane intersect.
bool Ocular::Math::Plane::intersects ( BoundsSphere const &  bounds,
IntersectionType *  result = nullptr 
) const

Performs an intersection test on a plane and sphere.

If the result is Inside, then the sphere is located entirely within the plane's positive half space.
If the result is Outside, then the sphere is located entirely outside the plane's positive half space.

The positive half space of the plane is the direction that the plane is facing, as described by it's normal.

As an example, say we have the plane defined as:

 Point: (0.0, 0.0, 0.0)
Normal: (0.0, 1.0, 0.0)

The plane is 'facing up' along the world origin.

If the intersection test returns Outside, then the AABB is entirely in the +y world space.
If the intersection test returns Inside, then the AABB is entirely in the -y world space.

Parameters
[in]bounds
[out]resultDetailed intersection result.
Returns
TRUE if the plane sphere AABB intersects, otherwise FALSE.
bool Ocular::Math::Plane::intersects ( BoundsAABB const &  bounds,
IntersectionType *  result = nullptr 
) const

Performs an intersection test on a plane and AABB.

If the result is Inside, then the AABB is located entirely within the plane's positive half space.
If the result is Outside, then the AABB is located entirely outside the plane's positive half space.

The positive half space of the plane is the direction that the plane is facing, as described by it's normal.

As an example, say we have the plane defined as:

 Point: (0.0, 0.0, 0.0)
Normal: (0.0, 1.0, 0.0)

The plane is 'facing up' along the world origin.

If the intersection test returns Outside, then the AABB is entirely in the +y world space.
If the intersection test returns Inside, then the AABB is entirely in the -y world space.

Parameters
[in]bounds
[out]resultDetailed intersection result.
Returns
TRUE if the plane and AABB intersects, otherwise FALSE.
bool Ocular::Math::Plane::intersects ( BoundsOBB const &  bounds,
IntersectionType *  result = nullptr 
) const

Performs an intersection test on a plane and OBB.

If the result is Inside, then the OBB is located entirely within the plane's positive half space.
If the result is Outside, then the OBB is located entirely outside the plane's positive half space.

The positive half space of the plane is the direction that the plane is facing, as described by it's normal.

As an example, say we have the plane defined as:

 Point: (0.0, 0.0, 0.0)
Normal: (0.0, 1.0, 0.0)

The plane is 'facing up' along the world origin.

If the intersection test returns Outside, then the OBB is entirely in the +y world space.
If the intersection test returns Inside, then the OBB is entirely in the -y world space.

Parameters
[in]bounds
[in]plane
[out]resultDetailed intersection result.
Returns
TRUE if the plane and OBB intersects, otherwise FALSE.
void Ocular::Math::Plane::setNormal ( Vector3f const &  normal)
Parameters
[in]normalThe direction of the plane.
void Ocular::Math::Plane::setPoint ( Vector3f const &  point)
Parameters
[in]pointA point on the plane to intersect with.

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