proj home

Files   Classes   Functions   Hierarchy  

halfspaceD3< PT, PD > Class Template Reference

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

#include <halfspaceD3.h>

Inheritance diagram for halfspaceD3< PT, PD >:
Collaboration diagram for halfspaceD3< PT, PD >:

List of all members.

Public Member Functions

 halfspaceD3 ()
 Construct in uninitialized state.
template<typename INDX >
 halfspaceD3 (PT const *pts, INDX i0, INDX i1, INDX i2)
 halfspaceD3 (PT const &p0_, PT const &p1_, PT const &p2_)
 Construct the plane with anticlockwise point ordering.
void set (PT const &p0_, PT const &p1_, PT const &p2_)
 Construct a half space from the ordered points.
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 p0
 Start point.
PT p1
 Second point.
PT p2
 End point.
PT normal
 Normal.


Detailed Description

template<typename PT, typename PD>
class halfspaceD3< PT, PD >

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 halfspaceD3.h.


Constructor & Destructor Documentation

template<typename PT, typename PD>
halfspaceD3< PT, PD >::halfspaceD3 (  )  [inline]

Construct in uninitialized state.

Definition at line 33 of file halfspaceD3.h.

00033 {}

template<typename PT, typename PD>
template<typename INDX >
halfspaceD3< PT, PD >::halfspaceD3 ( PT const *  pts,
INDX  i0,
INDX  i1,
INDX  i2 
) [inline]

Definition at line 37 of file halfspaceD3.h.

00043     : p0(pts[i0]), p1(pts[i1]), p2(pts[i2])
00044     { normalcalculate(); }

template<typename PT, typename PD >
halfspaceD3< PT, PD >::halfspaceD3 ( PT const &  p0_,
PT const &  p1_,
PT const &  p2_ 
) [inline]

Construct the plane with anticlockwise point ordering.

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

Definition at line 137 of file halfspaceD3.h.

00142   : p0(p0_), p1(p1_), p2(p2_)
00143 {
00144   normalcalculate();
00145 }


Member Function Documentation

template<typename PT, typename PD>
PD const halfspaceD3< PT, PD >::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 91 of file halfspaceD3.h.

Referenced by halfspaceD3test::test02().

00092     { 
00093       PT p;
00094       p.x=normal.x*normal.x*(p0.x-w.x);
00095       p.y=normal.y*normal.y*(p0.y-w.y);
00096       p.z=normal.z*normal.z*(p0.z-w.z);
00097       return p.x*p.x+p.y*p.y+p.z*p.z;
00098 /*
00099       return normal.x*normal.x*(p0.x-w.x)+
00100              normal.y*normal.y*(p0.y-w.y)+
00101              normal.z*normal.z*(p0.z-w.z);
00102 */
00103     }

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

Is the point inside the half space?

Implements partitionspace< PT >.

Definition at line 67 of file halfspaceD3.h.

Referenced by d4tess::initialize(), d4tess::surfaceviewable(), halfspaceD3test::test01(), and tetrahedron< PT, PD >::trianglei().

00068     { 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>
boolc halfspaceD3< PT, PD >::isInsideOrOnBoundary ( PT const &  x  )  const [inline]

Is the point on or inside the half space?

Definition at line 70 of file halfspaceD3.h.

Referenced by halfspaceD3test::test01().

00071     { 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 >
void halfspaceD3< PT, PD >::normalcalculate (  )  [inline]

Calculate the normal the ordered points.

Definition at line 125 of file halfspaceD3.h.

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

Referenced by halfspaceD3< T, D >::halfspaceD3().

00126 {
00127   PT u(p2 - p1);
00128   PT v(p0 - p1);
00129 
00130   normal.x=u.y*v.z-v.y*u.z;
00131   normal.y=u.z*v.x-u.x*v.z;
00132   normal.z=u.x*v.y-u.y*v.x;
00133 }

template<typename PT, typename PD >
void halfspaceD3< PT, PD >::set ( PT const &  p0_,
PT const &  p1_,
PT const &  p2_ 
) [inline]

Construct a half space from the ordered points.

Definition at line 149 of file halfspaceD3.h.

00154 {
00155   p0=p0_;
00156   p1=p1_;
00157   p2=p2_;
00158 
00159   normalcalculate();
00160 }


Member Data Documentation

template<typename PT, typename PD>
PT halfspaceD3< PT, PD >::normal

template<typename PT, typename PD>
PT halfspaceD3< PT, PD >::p0

template<typename PT, typename PD>
PT halfspaceD3< PT, PD >::p1

Second point.

Definition at line 26 of file halfspaceD3.h.

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

template<typename PT, typename PD>
PT halfspaceD3< PT, PD >::p2

End point.

Definition at line 28 of file halfspaceD3.h.

Referenced by halfspaceD3< PT, PD >::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