osg::Plane Class Reference

A plane class. It can be used to represent an infinite plane. More...

`#include <Plane>`

Inheritance diagram for osg::Plane:

## Public Types

enum | { num_components = 3 }
typedef double | value_type
typedef Vec3d | Vec3_type
typedef Vec4d | Vec4_type

## Public Member Functions

| Plane ()
| Default constructor.
| Plane (const Plane &pl)
| Plane (value_type a, value_type b, value_type c, value_type d)
| Constructor.
| Plane (const Vec4f &vec)
| Constructor.
| Plane (const Vec4d &vec)
| Constructor.
| Plane (const Vec3_type &norm, value_type d)
| Constructor.
| Plane (const Vec3_type &v1, const Vec3_type &v2, const Vec3_type &v3)
| Constructor.
| Plane (const Vec3_type &norm, const Vec3_type &point)
| Constructor.
Plane & | operator= (const Plane &pl)
void | set (const Plane &pl)
void | set (value_type a, value_type b, value_type c, value_type d)
void | set (const Vec4f &vec)
void | set (const Vec4d &vec)
void | set (const Vec3_type &norm, double d)
void | set (const Vec3_type &v1, const Vec3_type &v2, const Vec3_type &v3)
void | set (const Vec3_type &norm, const Vec3_type &point)
void | flip ()
void | makeUnitLength ()
void | calculateUpperLowerBBCorners ()
bool | valid () const
| Checks if all internal values describing the plane have valid numbers.
bool | isNaN () const
bool | operator== (const Plane &plane) const
bool | operator!= (const Plane &plane) const
bool | operator< (const Plane &plane) const
value_type * | ptr ()
const value_type * | ptr () const
Vec4_type | asVec4 () const
value_type & | operator[] (unsigned int i)
value_type | operator[] (unsigned int i) const
Vec3_type | getNormal () const
float | distance (const osg::Vec3f &v) const
double | distance (const osg::Vec3d &v) const
float | dotProductNormal (const osg::Vec3f &v) const
double | dotProductNormal (const osg::Vec3d &v) const
int | intersect (const std::vector< Vec3f > &vertices) const
int | intersect (const std::vector< Vec3d > &vertices) const
int | intersect (const BoundingSphere &bs) const
int | intersect (const BoundingBox &bb) const
void | transform (const osg::Matrix &matrix)
void | transformProvidingInverse (const osg::Matrix &matrix)

## Protected Attributes

value_type | _fv [4]
unsigned int | _upperBBCorner
unsigned int | _lowerBBCorner

## Detailed Description

A plane class. It can be used to represent an infinite plane.

The infinite plane is described by an implicit plane equation a*x+b*y+c*z+d = 0. Though it is not mandatory that a^2+b^2+c^2 = 1 is fulfilled in general some methods require it (

See also
  osg::Plane::distance).

## Member Typedef Documentation

## value_type

typedef double osg::Plane::value_type

Type of Plane class.

## Vec3_type

typedef Vec3d osg::Plane::Vec3_type

## Vec4_type

typedef Vec4d osg::Plane::Vec4_type

## Member Enumeration Documentation

## anonymous enum

anonymous enum

Number of vector components.

Enumerator
num_components |

## Constructor & Destructor Documentation

## Plane() [1/8]

osg::Plane::Plane | ( |  | ) |

inline

Default constructor.

The default constructor initializes all values to zero.

Warning
  Although the method osg::Plane::valid() will return true after the default constructors call the plane is mathematically invalid! Default data do not describe a valid plane.

References _fv, _lowerBBCorner, and _upperBBCorner.

Referenced by osg::InfinitePlane::InfinitePlane(), operator!=(), operator<(), operator=(), operator==(), Plane(), and set().

## Plane() [2/8]

osg::Plane::Plane | ( | const Plane & | pl | ) |

inline

References Plane(), and set().

## Plane() [3/8]

osg::Plane::Plane | ( | value_type | a,
|  | value_type | b,
|  | value_type | c,
|  | value_type | d )

inline

Constructor.

The plane is described as a*x+b*y+c*z+d = 0.

Remarks
  You may call osg::Plane::MakeUnitLength afterwards if the passed values are not normalized.

References set().

## Plane() [4/8]

osg::Plane::Plane | ( | const Vec4f & | vec | ) |

inline

Constructor.

The plane can also be described as vec*[x,y,z,1].

Remarks
  You may call osg::Plane::MakeUnitLength afterwards if the passed values are not normalized.

References set().

## Plane() [5/8]

osg::Plane::Plane | ( | const Vec4d & | vec | ) |

inline

Constructor.

The plane can also be described as vec*[x,y,z,1].

Remarks
  You may call osg::Plane::MakeUnitLength afterwards if the passed values are not normalized.

References set().

## Plane() [6/8]

osg::Plane::Plane | ( | const Vec3_type & | norm,
|  | value_type | d )

inline

Constructor.

This constructor initializes the internal values directly without any checking or manipulation.

Parameters

  norm | The normal of the plane.
  d | The negative distance from the point of origin to the plane.

Remarks
  You may call osg::Plane::MakeUnitLength afterwards if the passed normal was not normalized.

References set().

## Plane() [7/8]

osg::Plane::Plane | ( | const Vec3_type & | v1,
|  | const Vec3_type & | v2,
|  | const Vec3_type & | v3 )

inline

Constructor.

This constructor calculates from the three points describing an infinite plane the internal values.

Parameters

  v1 | Point in the plane.
  v2 | Point in the plane.
  v3 | Point in the plane.

Remarks
  After this constructor call the plane's normal is normalized in case the three points described a mathematically valid plane.
  The normal is determined by building the cross product of (v2-v1) ^ (v3-v2).

References set().

## Plane() [8/8]

osg::Plane::Plane | ( | const Vec3_type & | norm,
|  | const Vec3_type & | point )

inline

Constructor.

This constructor initializes the internal values directly without any checking or manipulation.

Parameters

  norm | The normal of the plane.
  point | A point of the plane.

Remarks
  You may call osg::Plane::MakeUnitLength afterwards if the passed normal was not normalized.

References set().

## Member Function Documentation

## asVec4()

Vec4_type osg::Plane::asVec4 | ( |  | ) | const

inline

References _fv.

## calculateUpperLowerBBCorners()

void osg::Plane::calculateUpperLowerBBCorners | ( |  | ) |

inline

calculate the upper and lower bounding box corners to be used in the intersect(BoundingBox&) method for speeding calculations.

References _fv, _lowerBBCorner, and _upperBBCorner.

Referenced by flip(), set(), and set().

## distance() [1/2]

double osg::Plane::distance | ( | const osg::Vec3d & | v | ) | const

inline

Calculate the distance between a point and the plane.

Remarks
  This method only leads to real distance values if the plane's norm is 1.

See also
  osg::Plane::makeUnitLength

References _fv, osg::Vec3d::x(), osg::Vec3d::y(), and osg::Vec3d::z().

## distance() [2/2]

float osg::Plane::distance | ( | const osg::Vec3f & | v | ) | const

inline

Calculate the distance between a point and the plane.

Remarks
  This method only leads to real distance values if the plane's norm is 1.

See also
  osg::Plane::makeUnitLength

References _fv, osg::Vec3f::x(), osg::Vec3f::y(), and osg::Vec3f::z().

Referenced by intersect(), intersect(), intersect(), and intersect().

## dotProductNormal() [1/2]

double osg::Plane::dotProductNormal | ( | const osg::Vec3d & | v | ) | const

inline

calculate the dot product of the plane normal and a point.

References _fv, osg::Vec3d::x(), osg::Vec3d::y(), and osg::Vec3d::z().

## dotProductNormal() [2/2]

float osg::Plane::dotProductNormal | ( | const osg::Vec3f & | v | ) | const

inline

calculate the dot product of the plane normal and a point.

References _fv, osg::Vec3f::x(), osg::Vec3f::y(), and osg::Vec3f::z().

## flip()

void osg::Plane::flip | ( |  | ) |

inline

flip/reverse the orientation of the plane.

References _fv, and calculateUpperLowerBBCorners().

## getNormal()

Vec3_type osg::Plane::getNormal | ( |  | ) | const

inline

References _fv.

## intersect() [1/4]

int osg::Plane::intersect | ( | const BoundingBox & | bb | ) | const

inline

intersection test between plane and bounding sphere. return 1 if the bs is completely above plane, return 0 if the bs intersects the plane, return -1 if the bs is completely below the plane.

References _lowerBBCorner, _upperBBCorner, osg::BoundingBoxImpl< VT >::corner(), and distance().

## intersect() [2/4]

int osg::Plane::intersect | ( | const BoundingSphere & | bs | ) | const

inline

intersection test between plane and bounding sphere. return 1 if the bs is completely above plane, return 0 if the bs intersects the plane, return -1 if the bs is completely below the plane.

References osg::BoundingSphereImpl< VT >::center(), distance(), and osg::BoundingSphereImpl< VT >::radius().

## intersect() [3/4]

int osg::Plane::intersect | ( | const std::vector< Vec3d > & | vertices | ) | const

inline

intersection test between plane and vertex list return 1 if the bs is completely above plane, return 0 if the bs intersects the plane, return -1 if the bs is completely below the plane.

References distance().

## intersect() [4/4]

int osg::Plane::intersect | ( | const std::vector< Vec3f > & | vertices | ) | const

inline

intersection test between plane and vertex list return 1 if the bs is completely above plane, return 0 if the bs intersects the plane, return -1 if the bs is completely below the plane.

References distance().

## isNaN()

bool osg::Plane::isNaN | ( |  | ) | const

inline

References _fv, and osg::isNaN().

Referenced by valid().

## makeUnitLength()

void osg::Plane::makeUnitLength | ( |  | ) |

inline

This method multiplies the coefficients of the plane equation with a constant factor so that the equation a^2+b^2+c^2 = 1 holds.

References _fv.

Referenced by transformProvidingInverse().

## operator!=()

bool osg::Plane::operator!= | ( | const Plane & | plane | ) | const

inline

References _fv, and Plane().

## operator<()

bool osg::Plane::operator< | ( | const Plane & | plane | ) | const

inline

A plane is said to be smaller than another plane if the first non-identical element of the internal array is smaller than the corresponding element of the other plane.

References _fv, and Plane().

## operator=()

Plane & osg::Plane::operator= | ( | const Plane & | pl | ) |

inline

References Plane(), and set().

## operator==()

bool osg::Plane::operator== | ( | const Plane & | plane | ) | const

inline

References _fv, and Plane().

## operator[]() [1/2]

value_type & osg::Plane::operator[] | ( | unsigned int | i | ) |

inline

References _fv.

## operator[]() [2/2]

value_type osg::Plane::operator[] | ( | unsigned int | i | ) | const

inline

References _fv.

## ptr() [1/2]

value_type * osg::Plane::ptr | ( |  | ) |

inline

References _fv.

## ptr() [2/2]

const value_type * osg::Plane::ptr | ( |  | ) | const

inline

References _fv.

## set() [1/7]

void osg::Plane::set | ( | const Plane & | pl | ) |

inline

References _fv, calculateUpperLowerBBCorners(), and Plane().

Referenced by osgParticle::DomainOperator::addDiskDomain(), osgParticle::DomainOperator::addPlaneDomain(), osgParticle::DomainOperator::addRectangleDomain(), osgParticle::DomainOperator::addTriangleDomain(), operator=(), Plane(), Plane(), Plane(), Plane(), Plane(), Plane(), Plane(), set(), set(), and transformProvidingInverse().

## set() [2/7]

void osg::Plane::set | ( | const Vec3_type & | norm,
|  | const Vec3_type & | point )

inline

References set().

## set() [3/7]

void osg::Plane::set | ( | const Vec3_type & | norm,
|  | double | d )

inline

References set().

Referenced by set().

## set() [4/7]

void osg::Plane::set | ( | const Vec3_type & | v1,
|  | const Vec3_type & | v2,
|  | const Vec3_type & | v3 )

inline

References osg::Vec3d::length(), set(), and osg::Vec3d::set().

## set() [5/7]

void osg::Plane::set | ( | const Vec4d & | vec | ) |

inline

References set().

Referenced by set().

## set() [6/7]

void osg::Plane::set | ( | const Vec4f & | vec | ) |

inline

References set().

Referenced by set().

## set() [7/7]

void osg::Plane::set | ( | value_type | a,
|  | value_type | b,
|  | value_type | c,
|  | value_type | d )

inline

References _fv, and calculateUpperLowerBBCorners().

## transform()

void osg::Plane::transform | ( | const osg::Matrix & | matrix | ) |

inline

Transform the plane by matrix. Note, this operation carries out the calculation of the inverse of the matrix since a plane must be multiplied by the inverse transposed to transform it. This make this operation expensive. If the inverse has been already calculated elsewhere then use transformProvidingInverse() instead. See http://www.worldserver.com/turk/computergraphics/NormalTransformations.pdf

References osg::Matrixd::invert(), and transformProvidingInverse().

## transformProvidingInverse()

void osg::Plane::transformProvidingInverse | ( | const osg::Matrix & | matrix | ) |

inline

Transform the plane by providing a pre inverted matrix. see transform for details.

References _fv, makeUnitLength(), and set().

Referenced by transform().

## valid()

bool osg::Plane::valid | ( |  | ) | const

inline

Checks if all internal values describing the plane have valid numbers.

Warning
  This method does not check if the plane is mathematically correctly described!

Remarks
  The only case where all elements have valid numbers and the plane description is invalid occurs if the plane's normal is zero.

References isNaN().

## Member Data Documentation

## _fv

value_type osg::Plane::_fv[4]

protected

Vec member variable.

Referenced by asVec4(), calculateUpperLowerBBCorners(), distance(), distance(), dotProductNormal(), dotProductNormal(), flip(), getNormal(), isNaN(), makeUnitLength(), operator!=(), operator<(), operator==(), operator[](), operator[](), Plane(), ptr(), ptr(), set(), set(), and transformProvidingInverse().

## _lowerBBCorner

unsigned int osg::Plane::_lowerBBCorner

protected

Referenced by calculateUpperLowerBBCorners(), intersect(), and Plane().

## _upperBBCorner

unsigned int osg::Plane::_upperBBCorner

protected

Referenced by calculateUpperLowerBBCorners(), intersect(), and Plane().

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

- Plane