inlib  1.2.0
Public Member Functions
inlib::a3::plane< T > Class Template Reference

List of all members.

Public Member Functions

 plane ()
 plane (const vec< T > &a_p0, const vec< T > &a_p1, const vec< T > &a_p2)
 plane (const vec< T > &a_normal, const T &a_distance)
 plane (const vec< T > &a_normal, const vec< T > &a_point)
virtual ~plane ()
 plane (const plane &a_from)
planeoperator= (const plane &a_from)
void offset (const T &a_distance)
bool intersect (const line< T > &a_line, vec< T > &a_intersection) const
bool is_in_half_space (const vec< T > &a_point) const
const vec< T > & normal () const
distance_from_origin () const
distance (const vec< T > &a_point) const

Detailed Description

template<class T>
class inlib::a3::plane< T >

Definition at line 329 of file a3.


Constructor & Destructor Documentation

template<class T>
inlib::a3::plane< T >::plane ( ) [inline]

Definition at line 331 of file a3.

{}
template<class T>
inlib::a3::plane< T >::plane ( const vec< T > &  a_p0,
const vec< T > &  a_p1,
const vec< T > &  a_p2 
) [inline]

Definition at line 333 of file a3.

                                                                  {
    // Construct a plane given 3 points.
    // Orientation is computed by taking (p1 - p0) x (p2 - p0) and
    // pointing the normal in that direction.
  
    vec<T> P = a_p1;
    P.subtract(a_p0);
    vec<T> P2 = a_p2;
    P2.subtract(a_p0);
    m_normal = P.cross(P2);
    m_normal.normalize();
    m_distance = 
      m_normal.v0() * a_p0.v0() + 
      m_normal.value1() * a_p0.value1() + 
      m_normal.value2() * a_p0.value2();
  }
template<class T>
inlib::a3::plane< T >::plane ( const vec< T > &  a_normal,
const T &  a_distance 
) [inline]

Definition at line 350 of file a3.

                                                   {
    // Construct a plane given normal and distance from origin along normal.
    // Orientation is given by the normal vector n.
    m_normal = a_normal;
    m_normal.normalize();
    m_distance = a_distance;
  }
template<class T>
inlib::a3::plane< T >::plane ( const vec< T > &  a_normal,
const vec< T > &  a_point 
) [inline]

Definition at line 358 of file a3.

                                                     {
    // Construct a plane given normal and a point to pass through
    // Orientation is given by the normal vector n.
    m_normal = a_normal;
    m_normal.normalize();
    m_distance = 
      m_normal.v0() * a_point.v0() + 
      m_normal.v1() * a_point.v1() + 
      m_normal.v2() * a_point.v2();
  }
template<class T>
virtual inlib::a3::plane< T >::~plane ( ) [inline, virtual]

Definition at line 369 of file a3.

{}
template<class T>
inlib::a3::plane< T >::plane ( const plane< T > &  a_from) [inline]

Definition at line 371 of file a3.

  :m_normal(a_from.m_normal)
  ,m_distance(a_from.m_distance)
  {}

Member Function Documentation

template<class T>
T inlib::a3::plane< T >::distance ( const vec< T > &  a_point) const [inline]

Definition at line 415 of file a3.

                                          {
    // Return the distance from point to plane. Positive distance means
    // the point is in the plane's half space.
    return a_point.dot(m_normal) - m_distance;
  }
template<class T>
T inlib::a3::plane< T >::distance_from_origin ( ) const [inline]

Definition at line 413 of file a3.

{return m_distance;}
template<class T>
bool inlib::a3::plane< T >::intersect ( const line< T > &  a_line,
vec< T > &  a_intersection 
) const [inline]

Definition at line 387 of file a3.

                                                                     {
    // Intersect line and plane, returning true if there is an intersection
    // false if line is parallel to plane
    const vec<T>& pos = a_line.position();
    const vec<T>& dir = a_line.direction();
    T d = m_normal.dot(dir);
    if(d==array<T>::zero()) return false;
    T t = (m_distance - m_normal.dot(pos))/d;
    a_intersection = dir;
    a_intersection.multiply(t);
    a_intersection.add(pos);
    //a_intersection = pos + t * dir;
    return true;
  }
template<class T>
bool inlib::a3::plane< T >::is_in_half_space ( const vec< T > &  a_point) const [inline]

Definition at line 402 of file a3.

                                                     {
    // Returns true if the given point is within the half-space
    // defined by the plane
    //vec pos = m_normal * m_distance;
    vec<T> pos = m_normal;
    pos.multiply(-m_distance);
    pos.add(a_point);
    return (m_normal.dot(pos) >= array<T>::zero() ? true : false);
  }
template<class T>
const vec<T>& inlib::a3::plane< T >::normal ( ) const [inline]

Definition at line 412 of file a3.

{return m_normal;}
template<class T>
void inlib::a3::plane< T >::offset ( const T &  a_distance) [inline]

Definition at line 382 of file a3.

                                  {
    // Offset a plane by a given distance.
    m_distance += a_distance;
  }
template<class T>
plane& inlib::a3::plane< T >::operator= ( const plane< T > &  a_from) [inline]

Definition at line 375 of file a3.

                                        {
    m_normal = a_from.m_normal;
    m_distance = a_from.m_distance;
    return *this;
  }

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines