Public Member Functions | Public Attributes

gmtl::Plane< DATA_TYPE > 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< DATA_TYPE >:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Plane ()
 Creates an uninitialized Plane.
 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.
 Plane (const Vec< DATA_TYPE, 3 > &norm, const Point< DATA_TYPE, 3 > &pt)
 Creates a plane with the given normal on which pt resides.
 Plane (const Vec< DATA_TYPE, 3 > &norm, const DATA_TYPE &dPlaneConst)
 Creates a plane with the given normal and offset.
 Plane (const Plane< DATA_TYPE > &plane)
 Creates an exact duplicate of the given plane.
const Vec< DATA_TYPE, 3 > & getNormal () const
 Gets the normal for this plane.
void setNormal (const Vec< DATA_TYPE, 3 > &norm)
 Sets the normal for this plane to the given vector.
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.
void setOffset (const DATA_TYPE &offset)
 Sets the offset of this plane from the origin.

Public Attributes

Vec< DATA_TYPE, 3 > mNorm
 The normal for this vector.
DATA_TYPE mOffset
 This plane's offset from the origin such that for any point pt, dot( pt, mNorm ) = mOffset.

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 36 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 43 of file Plane.h.

      : mOffset( 0 )
   {}

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 54 of file Plane.h.

   {
      Vec<DATA_TYPE, 3> vec12( pt2-pt1 );
      Vec<DATA_TYPE, 3> vec13( pt3-pt1 );

      cross( mNorm, vec12, vec13 );
      normalize( mNorm );

      mOffset = dot( static_cast< Vec<DATA_TYPE, 3> >(pt1), mNorm );  // Graphics Gems I: Page 390
   }

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 72 of file Plane.h.

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

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 84 of file Plane.h.

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

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 93 of file Plane.h.

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


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 102 of file Plane.h.

   {
      return mNorm;
   }

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 125 of file Plane.h.

   {
      return mOffset;
   }

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 114 of file Plane.h.

   {
      mNorm = norm;
   }

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 135 of file Plane.h.

   {
      mOffset = offset;
   }


Member Data Documentation

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

The normal for this vector.

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

Definition at line 146 of file Plane.h.

template<class DATA_TYPE>
DATA_TYPE gmtl::Plane< DATA_TYPE >::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 153 of file Plane.h.


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