Core 1.0
Plane Class Reference

A plane defined by its analytic equation. More...

#include <plane.h>

Inheritance diagram for Plane:
Slab

Public Member Functions

 Plane ()
 Empty.
 
 Plane (const double &, const double &, const double &, const double &)
 Creates a plane given its analytic equation.
 
 Plane (const Vector &, const double &)
 Creates a plane given normal and distance.
 
 Plane (const Vector &, const Vector &)
 Creates a plane given normal and vertex.
 
 Plane (const Vector &)
 Creates a plane given normal passing through the origin.
 
 ~Plane ()
 Empty.
 
bool Intersect (const Ray &, double &) const
 Compute the intersection between a plane and a ray.
 
bool Inside (const Vector &) const
 Check if a point is inside or outside the plane.
 
int Side (const Vector &) const
 Check if a point lies inside, outside or even on the plane.
 
Vector Normal () const
 Returns the normal to the plane.
 
Vector Vertex () const
 Finds a vertex on the plane.
 
double Coeff () const
 Returns the coefficient of the plane.
 
double R (const Vector &) const
 Compute the squared distance to the half space delimited by the plane.
 
double Signed (const Vector &) const
 Compute the signed distance between a point and the plane.
 
double Eval (const Vector &) const
 Evaluates the equation of the plane.
 
void Transform (const Matrix4 &)
 Transforms a plane given a homogeneous transformation matrix.
 
void Translate (const double &)
 Translates a plane in the direction of its normal.
 
void Rotate (const Matrix &)
 Rotate a plane.
 
void Scale (const double &)
 Scale a plane.
 
Vector Symmetry (const Vector &) const
 Compute the point symmetric to the argument point.
 
Box Symmetric (const Box &) const
 Compute the bounding box of the symmetric argument box.
 
Segment Symmetric (const Segment &) const
 Compute the symmetric segment.
 
Sphere Symmetric (const Sphere &) const
 Compute the symmetric sphere.
 
Vector Reflect (const Vector &) const
 Compute the reflected direction.
 
bool Refract (const Vector &, const double &, Vector &) const
 Compute the refracted direction.
 
Vector Intersect (const Line &) const
 Compute the intersection between a plane and a line.
 
bool Intersect (const Segment &, double &) const
 Compute the intersection between a plane and a segment.
 
Quadric Equation (const Ray &) const
 Compute the quadric equation of the Euclidean distance to the plane.
 
Frame GetFrame () const
 Return a Frame attached to the plane.
 
Axis Intersect (const Plane &) const
 Compute the intesection between two planes.
 

Static Public Member Functions

static void Cast (const Vector &, double &, double &)
 Compute the inverse mapping coordinates of a point.
 
static Vector Intersection (const Plane &, const Plane &, const Plane &)
 Compute the intersection between three planes.
 
static QVector< VectorConvexPoints (const QVector< Plane > &)
 Compute the intersection of a set of half spaces.
 
static Vector Reflect (const Vector &, const Vector &)
 Given an input (normalized) normal, compute a reflected direction. The code is the same as:
 
static bool Refract (const Vector &, const Vector &, const double &, Vector &)
 Compute the refracted direction.
 

Static Public Attributes

static const double epsilon = 1e-06
 Small value for checking intersection with a ray.
 
static const Plane XY
 Reference z-axis horizontal plane.
 
static const Plane YZ
 Reference x-axis plane.
 
static const Plane ZX
 Reference y-axis plane.
 

Protected Attributes

Vector n = Vector::Z
 Plane normal.
 
double c = 0.0
 Plane coefficient.
 

Friends

std::ostream & operator<< (std::ostream &s, const Plane &plane)
 Overloaded.
 

Detailed Description

A plane defined by its analytic equation.

This class serves as a base core class for binary space patitionning or constructive solid geometry in ray-tracing.

Constructor & Destructor Documentation

◆ Plane() [1/4]

Plane::Plane ( const double & a,
const double & b,
const double & c,
const double & d )
inlineexplicit

Creates a plane given its analytic equation.

Parameters
a,b,cCoefficients of the plane normal, the plane normal should be unit..
dPlane constant.

◆ Plane() [2/4]

Plane::Plane ( const Vector & n,
const double & c )
inlineexplicit

Creates a plane given normal and distance.

Parameters
nPlane normal, should be unit.
cPlane constant.

◆ Plane() [3/4]

Plane::Plane ( const Vector & n,
const Vector & p )
explicit

Creates a plane given normal and vertex.

Parameters
nPlane normal, should be unit.
pAny point on the plane.

◆ Plane() [4/4]

Plane::Plane ( const Vector & n)
explicit

Creates a plane given normal passing through the origin.

Parameters
nPlane normal, should be unit.

Member Function Documentation

◆ Cast()

void Plane::Cast ( const Vector & p,
double & u,
double & v )
static

Compute the inverse mapping coordinates of a point.

Parameters
pPoint that will be projected on the plane.
u,vReturned coordinates.

◆ ConvexPoints()

QVector< Vector > Plane::ConvexPoints ( const QVector< Plane > & planes)
static

Compute the intersection of a set of half spaces.

This is a O(n^4) algorithm

A better version in O(n^3) could be implemented: see Finding the Intersection of Half-Spaces in Time O(n ln n). Preparata and Muller, Theoretical Computer Science 8, 45-55, 1979.

Returns a set of point representing the minimal convex polygon embedding all half spaces. The function doesn't check if the intersection is bounded or not.

Parameters
planesSet of planes.

◆ Equation()

Quadric Plane::Equation ( const Ray & ray) const

Compute the quadric equation of the Euclidean distance to the plane.

Parameters
rayThe ray.

◆ Eval()

double Plane::Eval ( const Vector & p) const
inline

Evaluates the equation of the plane.

This can be interpreted as a signed distance to the plane.

Parameters
pPoint.
See also
Plane::R(), Plane::Signed()

◆ GetFrame()

Frame Plane::GetFrame ( ) const

Return a Frame attached to the plane.

See also
Axis::GetFrame()

◆ Inside()

bool Plane::Inside ( const Vector & p) const

Check if a point is inside or outside the plane.

This function compares the sign strictly to 0.0, use Plane::Side() for a more fuzzy implementation.

Parameters
pPoint.
See also
Plane::Side().

◆ Intersect() [1/4]

Vector Plane::Intersect ( const Line & l) const

Compute the intersection between a plane and a line.

The line should not be parallel to the plane.

Parameters
lThe line.

◆ Intersect() [2/4]

Axis Plane::Intersect ( const Plane & plane) const

Compute the intesection between two planes.

Planes should not be coplanar.

Parameters
planeArgument plane.

◆ Intersect() [3/4]

bool Plane::Intersect ( const Ray & ray,
double & t ) const

Compute the intersection between a plane and a ray.

The intersection depth is returned if intersection occurs.

Parameters
rayThe ray.
tIntersection depth.

◆ Intersect() [4/4]

bool Plane::Intersect ( const Segment & s,
double & t ) const

Compute the intersection between a plane and a segment.

The intersection point can be computed using Segment::Vertex(const double&) if intersection occurs.

See also
Plane::Intersect(const Line&) const
Plane::Intersect(const Ray&) const
Parameters
sThe segment.
tPosition of the point if intersection occurs.

◆ Intersection()

Vector Plane::Intersection ( const Plane & a,
const Plane & b,
const Plane & c )
static

Compute the intersection between three planes.

Returns Vector::Null if two planes are complanar.

Parameters
a,b,cThree planes.

◆ R()

double Plane::R ( const Vector & p) const

Compute the squared distance to the half space delimited by the plane.

Parameters
pPoint.
See also
Plane::Eval()

◆ Reflect() [1/2]

Vector Plane::Reflect ( const Vector & d) const
inline

Compute the reflected direction.

Parameters
dDirection.

◆ Reflect() [2/2]

Vector Plane::Reflect ( const Vector & d,
const Vector & n )
inlinestatic

Given an input (normalized) normal, compute a reflected direction. The code is the same as:

Vector r=d-2.0*(n*d)*n;
Vector n
Plane normal.
Definition plane.h:20
Vectors in three dimensions.
Definition evector.h:20

◆ Refract() [1/2]

bool Plane::Refract ( const Vector & d,
const double & eta,
Vector & r ) const

Compute the refracted direction.

Parameters
dDirection.
etaIndex of incoming ray medium divided by the index of the other material.
rRefracted direction.

◆ Refract() [2/2]

bool Plane::Refract ( const Vector & d,
const Vector & n,
const double & eta,
Vector & r )
static

Compute the refracted direction.

Parameters
dDirection.
nNormal.
etaIndex of incoming ray medium divided by the index of the other material.
rRefracted direction.

◆ Rotate()

void Plane::Rotate ( const Matrix & r)

Rotate a plane.

Parameters
rRotation matrix.

◆ Scale()

void Plane::Scale ( const double & s)

Scale a plane.

Parameters
sScaling factor.

◆ Side()

int Plane::Side ( const Vector & p) const

Check if a point lies inside, outside or even on the plane.

The epsilon tolerance used for testing if the point is on the plane is 10-6.

Parameters
pPoint.

◆ Signed()

double Plane::Signed ( const Vector & p) const

Compute the signed distance between a point and the plane.

Parameters
pThe point.
See also
Plane::Eval(const Vector&) const

◆ Symmetric() [1/3]

Box Plane::Symmetric ( const Box & box) const

Compute the bounding box of the symmetric argument box.

Parameters
boxThe box.

◆ Symmetric() [2/3]

Segment Plane::Symmetric ( const Segment & segment) const

Compute the symmetric segment.

Parameters
segmentThe segment.

◆ Symmetric() [3/3]

Sphere Plane::Symmetric ( const Sphere & sphere) const

Compute the symmetric sphere.

Parameters
sphereThe sphere.

◆ Symmetry()

Vector Plane::Symmetry ( const Vector & p) const

Compute the point symmetric to the argument point.

Parameters
pPoint.

◆ Transform()

void Plane::Transform ( const Matrix4 & M)

Transforms a plane given a homogeneous transformation matrix.

Parameters
MMatrix.

◆ Translate()

void Plane::Translate ( const double & t)

Translates a plane in the direction of its normal.

Parameters
tTranslation distance.

◆ Vertex()

Vector Plane::Vertex ( ) const

Finds a vertex on the plane.

Basically computes the point on the plane which is nearest to the origin.

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream & s,
const Plane & plane )
friend

Overloaded.

Parameters
sStream.
planeThe plane.