proj home

Files   Classes   Functions   Hierarchy  

halfspaceD3indexed< PT, PD, INDX > Class Template Reference

Define a 3D half space with three ordered points. More...

#include <halfspaceD3indexed.h>

Inheritance diagram for halfspaceD3indexed< PT, PD, INDX >:
Collaboration diagram for halfspaceD3indexed< PT, PD, INDX >:

List of all members.

Public Member Functions

 halfspaceD3indexed (PT const *pts, INDX i0_, INDX i1_, INDX i2_)
 Construct the plane with anticlockwise point ordering.
void normalcalculate ()
 Calculate the normal the ordered points.
boolc isInside (PT const &x) const
 Is the point inside the half space?
boolc isInsideOrOnBoundary (PT const &x) const
 Is the point on or inside the half space?
PD const distancefromhalfspace (PT const &w) const
 A measure of the distance from the plane to the point w without a square root.

Public Attributes

PT const & p0
 Start point.
PT const & p1
 Second point.
PT const & p2
 End point.
PT normal
 Normal.
INDX i0
 Index to p0.
INDX i1
 Index to p1.
INDX i2
 Index to p2.


Detailed Description

template<typename PT, typename PD, typename INDX>
class halfspaceD3indexed< PT, PD, INDX >

Define a 3D half space with three ordered points.

The inside of the half space is on the anti clockwise side of the plane with the three points.

Definition at line 19 of file halfspaceD3indexed.h.


Constructor & Destructor Documentation

template<typename PT, typename PD, typename INDX>
halfspaceD3indexed< PT, PD, INDX >::halfspaceD3indexed ( PT const *  pts,
INDX  i0_,
INDX  i1_,
INDX  i2_ 
) [inline]

Construct the plane with anticlockwise point ordering.

The normal is outwards on the anticlockwise side of the plane.

Definition at line 43 of file halfspaceD3indexed.h.

References halfspaceD3indexed< PT, PD, INDX >::normalcalculate().

00049     : p0(pts[i0_]), p1(pts[i1_]), p2(pts[i2_]),
00050       i0(i0_), i1(i1_), i2(i2_)
00051     { normalcalculate(); }


Member Function Documentation

template<typename PT, typename PD, typename INDX>
PD const halfspaceD3indexed< PT, PD, INDX >::distancefromhalfspace ( PT const &  w  )  const [inline]

A measure of the distance from the plane to the point w without a square root.

ie N^2*d^2 where d is the vanilla distance function.

Definition at line 66 of file halfspaceD3indexed.h.

References halfspaceD3indexed< PT, PD, INDX >::normal, and halfspaceD3indexed< PT, PD, INDX >::p0.

00067     { 
00068       PT p;
00069       p.x=normal.x*normal.x*(p0.x-w.x);
00070       p.y=normal.y*normal.y*(p0.y-w.y);
00071       p.z=normal.z*normal.z*(p0.z-w.z);
00072       return p.x*p.x+p.y*p.y+p.z*p.z;
00073     }

template<typename PT, typename PD, typename INDX>
boolc halfspaceD3indexed< PT, PD, INDX >::isInside ( PT const &  x  )  const [inline, virtual]

Is the point inside the half space?

Implements partitionspace< PT >.

Definition at line 57 of file halfspaceD3indexed.h.

References halfspaceD3indexed< PT, PD, INDX >::normal, and halfspaceD3indexed< PT, PD, INDX >::p0.

00058     { return 0 < normal.x*(x.x-p0.x)+normal.y*(x.y-p0.y)+normal.z*(x.z-p0.z); }

template<typename PT, typename PD, typename INDX>
boolc halfspaceD3indexed< PT, PD, INDX >::isInsideOrOnBoundary ( PT const &  x  )  const [inline]

Is the point on or inside the half space?

Definition at line 60 of file halfspaceD3indexed.h.

References halfspaceD3indexed< PT, PD, INDX >::normal, and halfspaceD3indexed< PT, PD, INDX >::p0.

00061     { return 0 < zero<PD>::val+normal.x*(x.x-p0.x)+normal.y*(x.y-p0.y)+normal.z*(x.z-p0.z); }

template<typename PT , typename PD , typename INDX >
void halfspaceD3indexed< PT, PD, INDX >::normalcalculate (  )  [inline]

Calculate the normal the ordered points.

Definition at line 82 of file halfspaceD3indexed.h.

References halfspaceD3indexed< PT, PD, INDX >::normal, halfspaceD3indexed< PT, PD, INDX >::p0, halfspaceD3indexed< PT, PD, INDX >::p1, and halfspaceD3indexed< PT, PD, INDX >::p2.

Referenced by halfspaceD3indexed< PT, PD, INDX >::halfspaceD3indexed().

00083 {
00084   PT u(p2 - p1);
00085   PT v(p0 - p1);
00086 
00087   normal.x=u.y*v.z-v.y*u.z;
00088   normal.y=u.z*v.x-u.x*v.z;
00089   normal.z=u.x*v.y-u.y*v.x;
00090 }


Member Data Documentation

template<typename PT, typename PD, typename INDX>
INDX halfspaceD3indexed< PT, PD, INDX >::i0

Index to p0.

Definition at line 33 of file halfspaceD3indexed.h.

template<typename PT, typename PD, typename INDX>
INDX halfspaceD3indexed< PT, PD, INDX >::i1

Index to p1.

Definition at line 35 of file halfspaceD3indexed.h.

template<typename PT, typename PD, typename INDX>
INDX halfspaceD3indexed< PT, PD, INDX >::i2

Index to p2.

Definition at line 37 of file halfspaceD3indexed.h.

template<typename PT, typename PD, typename INDX>
PT halfspaceD3indexed< PT, PD, INDX >::normal

template<typename PT, typename PD, typename INDX>
PT const& halfspaceD3indexed< PT, PD, INDX >::p0

template<typename PT, typename PD, typename INDX>
PT const& halfspaceD3indexed< PT, PD, INDX >::p1

Second point.

Definition at line 26 of file halfspaceD3indexed.h.

Referenced by halfspaceD3indexed< PT, PD, INDX >::normalcalculate().

template<typename PT, typename PD, typename INDX>
PT const& halfspaceD3indexed< PT, PD, INDX >::p2

End point.

Definition at line 28 of file halfspaceD3indexed.h.

Referenced by halfspaceD3indexed< PT, PD, INDX >::normalcalculate().


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

Generated on Fri Mar 4 00:50:02 2011 for Chelton Evans Source by  doxygen 1.5.8