syBR::Core::Plane Class Reference

3D plane class More...

#include <Plane.hpp>

List of all members.

Public Types

enum  Classify { CLASSIFY_FRONT_OF_PLANE = 0, CLASSIFY_BACK_OF_PLANE, CLASSIFY_ON_PLANE }
 Position of a vector comparing to a plane. More...

Public Member Functions

 Plane ()
 Constructor #1.
 Plane (const Vector3D &normal, const float d)
 Constructor #2.
 Plane (const Plane &plane)
 Copy constructor.
const float getNormalX () const
 Get the x coordinate of the normal.
const float getNormalY () const
 Get the y coordinate of the normal.
const float getNormalZ () const
 Get the z coordinate of the normal.
const Vector3DgetNormal () const
 Get the normal.
const float getD () const
 Get the d parametre.
void set (const float a, const float b, const float c, const float d)
 Set the coordinates of the plane.
void set (const Vector3D &normal, const float d)
 Set the coordinates of the plane.
void from3Vertices (const Vector3D &vec1, const Vector3D &vec2, const Vector3D &vec3)
 Build the plane from three vertices.
float calculateDistanceToVector (const Vector3D &vec) const
 Calculate the distance between the plane and a vector.
Classify classifyVector (const Vector3D &vec) const
 Classify a vector against the plane.
Plane normalize () const
 Return a normalized plane which has the same normal as this plane.

Private Attributes

Vector3D m_normal
 Parametre of the ax+by+cz+d=0 equation of the plane.
float m_d
 Parametre of the ax+by+cz+d=0 equation of the plane.


Detailed Description

3D plane class

A plane is represented using the ax+by+cz+d=0 equation where (a,b,c) is the normal and d is the translation parametre.


Member Enumeration Documentation

enum syBR::Core::Plane::Classify

Position of a vector comparing to a plane.

Enumerator:
CLASSIFY_FRONT_OF_PLANE  In front of the plane.
CLASSIFY_BACK_OF_PLANE  Behind the plane.
CLASSIFY_ON_PLANE  On the plane.


Constructor & Destructor Documentation

syBR::Core::Plane::Plane (  ) 

Constructor #1.

syBR::Core::Plane::Plane ( const Vector3D normal,
const float  d 
)

Constructor #2.

Parameters:
normal Vector to be used a the normal
d d parametre of the plane

syBR::Core::Plane::Plane ( const Plane plane  ) 

Copy constructor.

Parameters:
plane Plane from which normal/d must be copied


Member Function Documentation

const float syBR::Core::Plane::getNormalX (  )  const

Get the x coordinate of the normal.

Returns:
x coordinate of the normal

const float syBR::Core::Plane::getNormalY (  )  const

Get the y coordinate of the normal.

Returns:
y coordinate of the normal

const float syBR::Core::Plane::getNormalZ (  )  const

Get the z coordinate of the normal.

Returns:
z coordinate of the normal

const Vector3D & syBR::Core::Plane::getNormal (  )  const

Get the normal.

Returns:
Vector which has the coordinates of the normal

const float syBR::Core::Plane::getD (  )  const

Get the d parametre.

Returns:
d parametre

void syBR::Core::Plane::set ( const float  a,
const float  b,
const float  c,
const float  d 
)

Set the coordinates of the plane.

Parameters:
a x coordinate of the normal
b y coordinate of the normal
c z coordinate of the normal
d d parametre of the plane

void syBR::Core::Plane::set ( const Vector3D normal,
const float  d 
)

Set the coordinates of the plane.

Parameters:
normal Vector to be used a the normal
d d parametre of the plane

void syBR::Core::Plane::from3Vertices ( const Vector3D vec1,
const Vector3D vec2,
const Vector3D vec3 
)

Build the plane from three vertices.

The calculation are quite the same as in MathHelpers::getFaceNormal(). It calculates the normal of the face made of the three vectors and then, get the d parametre by doing the dot product of the normal and one of the three vectors.

Parameters:
vec1 Vector #1 to be used for building
vec2 Vector #2 to be used for building
vec3 Vector #3 to be used for building

float syBR::Core::Plane::calculateDistanceToVector ( const Vector3D vec  )  const

Calculate the distance between the plane and a vector.

Parameters:
vec Vector for which the distance must be calculated
Returns:
Distance between the plane and the vector

Plane::Classify syBR::Core::Plane::classifyVector ( const Vector3D vec  )  const

Classify a vector against the plane.

Check the position of the vector comparing to the plane.

Parameters:
vec Vector to be classified
Returns:
Position of the vector compared to the plane (in front, in the back or on the plane)

Plane syBR::Core::Plane::normalize (  )  const

Return a normalized plane which has the same normal as this plane.

It gets the length of the normal and divide each of its coordinates by this length (even the d parametre).

Returns:
One of these:
  • Corresponding normalized plane if length of normal is not null
  • Same plane otherwise


Member Data Documentation

Vector3D syBR::Core::Plane::m_normal [private]

Parametre of the ax+by+cz+d=0 equation of the plane.

float syBR::Core::Plane::m_d [private]

Parametre of the ax+by+cz+d=0 equation of the plane.


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

Copyright © 2008 by Sebastien Frippiat
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License.
Last modified Tue Dec 30 17:57:33 2008