Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

gmtl::Plane Class Template Reference
[Abstract Data Types: Matrix, Vec, Quat, Coord, Sphere, Plane]

Plane: Defines a geometrical plane. More...

#include <Plane.h>

Collaboration diagram for gmtl::Plane:

Collaboration graph
[legend]
List of all members.

Public Methods

 Plane ()
 Creates an uninitialized Plane. More...

 Plane (const Point< DATA_TYPE, 3 > &pt1, const Point< DATA_TYPE, 3 > &pt2, const Point< DATA_TYPE, 3 > &pt3)
 Creates a plane that the given points lie on. More...

 Plane (const Vec< DATA_TYPE, 3 > &norm, const Point< DATA_TYPE, 3 > &pt)
 Creates a plane with the given normal on which pt resides. More...

 Plane (const Vec< DATA_TYPE, 3 > &norm, const DATA_TYPE &dPlaneConst)
 Creates a plane with the given normal and offset. More...

 Plane (const Plane< DATA_TYPE > &plane)
 Creates an exact duplicate of the given plane. More...

const Vec< DATA_TYPE, 3 > & getNormal () const
 Gets the normal for this plane. More...

void setNormal (const Vec< DATA_TYPE, 3 > &norm)
 Sets the normal for this plane to the given vector. More...

const DATA_TYPE & getOffset () const
 Gets the offset of this plane from the origin such that the offset is the negative distance from the origin. More...

void setOffset (const DATA_TYPE &offset)
 Sets the offset of this plane from the origin. More...


Public Attributes

Vec< DATA_TYPE, 3 > mNorm
 The normal for this vector. More...

DATA_TYPE mOffset
 This plane's offset from the origin such that for any point pt, dot( pt, mNorm ) = mOffset. More...


Detailed Description

template<class DATA_TYPE>
class gmtl::Plane< DATA_TYPE >

Plane: Defines a geometrical plane.

All points on the plane satify the equation dot(Pt,Normal) = offset normal is assumed to be normalized

NOTE: Some plane implementation store D instead of offset. Thus those implementation have opposite sign from what we have

pg. 309 Computer Graphics 2nd Edition Hearn Baker

  N dot P = -D
   |
   |-d-|
 __|___|-->N
   |   |
 *

Definition at line 65 of file Plane.h.


Constructor & Destructor Documentation

template<class DATA_TYPE>
gmtl::Plane< DATA_TYPE >::Plane   [inline]
 

Creates an uninitialized Plane.

In other words, the normal is (0,0,0) and the offset is 0.

Definition at line 72 of file Plane.h.

References mOffset.

00073       : mOffset( 0 )
00074    {}

template<class DATA_TYPE>
gmtl::Plane< DATA_TYPE >::Plane const Point< DATA_TYPE, 3 > &    pt1,
const Point< DATA_TYPE, 3 > &    pt2,
const Point< DATA_TYPE, 3 > &    pt3
[inline]
 

Creates a plane that the given points lie on.

Parameters:
pt1  a point on the plane
pt2  a point on the plane
pt3  a point on the plane

Definition at line 83 of file Plane.h.

References gmtl::cross, gmtl::dot, mNorm, mOffset, and gmtl::normalize.

00085    {
00086       Vec<DATA_TYPE, 3> vec12( pt2-pt1 );
00087       Vec<DATA_TYPE, 3> vec13( pt3-pt1 );
00088 
00089       mNorm = cross( vec12, vec13 );
00090       normalize( mNorm );
00091 
00092       mOffset = dot( static_cast< Vec<DATA_TYPE, 3> >(pt1), mNorm );  // Graphics Gems I: Page 390
00093    }

template<class DATA_TYPE>
gmtl::Plane< DATA_TYPE >::Plane const Vec< DATA_TYPE, 3 > &    norm,
const Point< DATA_TYPE, 3 > &    pt
[inline]
 

Creates a plane with the given normal on which pt resides.

Parameters:
norm  the normal of the plane
pt  a point that lies on the plane

Definition at line 101 of file Plane.h.

References gmtl::dot, mNorm, and mOffset.

00102       : mNorm( norm )
00103    {
00104       mOffset = dot( static_cast< Vec<DATA_TYPE, 3> >(pt), norm );
00105    }

template<class DATA_TYPE>
gmtl::Plane< DATA_TYPE >::Plane const Vec< DATA_TYPE, 3 > &    norm,
const DATA_TYPE &    dPlaneConst
[inline]
 

Creates a plane with the given normal and offset.

Parameters:
norm  the normal of the plane
dPlaneConst  the plane offset constant

Definition at line 113 of file Plane.h.

References mNorm, and mOffset.

00114       : mNorm( norm ), mOffset( dPlaneConst )
00115    {}

template<class DATA_TYPE>
gmtl::Plane< DATA_TYPE >::Plane const Plane< DATA_TYPE > &    plane [inline]
 

Creates an exact duplicate of the given plane.

Parameters:
plane  the plane to copy

Definition at line 122 of file Plane.h.

References mNorm, and mOffset.

00123       : mNorm( plane.mNorm ), mOffset( plane.mOffset )
00124    {}


Member Function Documentation

template<class DATA_TYPE>
const Vec<DATA_TYPE, 3>& gmtl::Plane< DATA_TYPE >::getNormal   const [inline]
 

Gets the normal for this plane.

Returns:
this plane's normal vector

Definition at line 131 of file Plane.h.

References mNorm.

00132    {
00133       return mNorm;
00134    }

template<class DATA_TYPE>
const DATA_TYPE& gmtl::Plane< DATA_TYPE >::getOffset   const [inline]
 

Gets the offset of this plane from the origin such that the offset is the negative distance from the origin.

Returns:
this plane's offset

Definition at line 154 of file Plane.h.

References mOffset.

00155    {
00156       return mOffset;
00157    }

template<class DATA_TYPE>
void gmtl::Plane< DATA_TYPE >::setNormal const Vec< DATA_TYPE, 3 > &    norm [inline]
 

Sets the normal for this plane to the given vector.

Parameters:
norm  the new normalized vector
Precondition:
|norm| = 1

Definition at line 143 of file Plane.h.

References mNorm.

00144    {
00145       mNorm = norm;
00146    }

template<class DATA_TYPE>
void gmtl::Plane< DATA_TYPE >::setOffset const DATA_TYPE &    offset [inline]
 

Sets the offset of this plane from the origin.

Parameters:
offset  the new offset

Definition at line 164 of file Plane.h.

References mOffset.

00165    {
00166       mOffset = offset;
00167    }


Member Data Documentation

template<class DATA_TYPE>
Vec<DATA_TYPE, 3> gmtl::Plane::mNorm
 

The normal for this vector.

For any point on the plane, dot( pt, mNorm) = mOffset.

Definition at line 175 of file Plane.h.

Referenced by getNormal, Plane, and setNormal.

template<class DATA_TYPE>
DATA_TYPE gmtl::Plane::mOffset
 

This plane's offset from the origin such that for any point pt, dot( pt, mNorm ) = mOffset.

Note that mOffset = -D (neg dist from the origin).

Definition at line 182 of file Plane.h.

Referenced by getOffset, Plane, and setOffset.


The documentation for this class was generated from the following file:
Generated on Mon Apr 7 15:29:29 2003 for GenericMathTemplateLibrary by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002