Files Classes Functions Hierarchy
#include <halfspaceD2.h>
Public Member Functions | |
| halfspaceD2 () | |
| Construct in uninitialized state. | |
| halfspaceD2 (PT const &p0_, PT const &p1_) | |
| Construct a half space from the ordered points. | |
| void | set (PT const &p0_, PT const &p1_) |
| 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? | |
| template<typename U > | |
| void | pointOnLine (PT &x, U const t) const |
| Line [p0,p1] for t=[0,1]. | |
| boolc | intersectionIn_t (PT &t, PT const &a, PT const &b) const |
| Solve (t.x,t.y) : a+(-a+b)t.x = pointOnLine(t.y). | |
| boolc | intersection (PT &p, PT const &a, PT const &b) const |
| Find the intersection of the line through (a,b) and this line. | |
| boolc | isOnBoundary (PT const &w) const |
| The client configures zero for the isOnBoundary routine. | |
| boolc | clip (PD &t0, PD &t1, PT const &a, PT const &m) const |
| Clip the line segment if cutting the half-space. | |
| boolc | clipNeg (PD &t0, PD &t1, PT const &a, PT const &m) const |
| Invert the clip. | |
| void | minimizepointtoline (PD &t, PT const &w) const |
| Find the nearest point on the line to w. | |
| PD const | distancefromhalfspace (PT const &w) const |
| A measure of the minimum distance from the line to the point w without a square root. | |
| operator stringc () const | |
| Serialize this object by writing it out as a string. | |
| stringc | print () const |
| For debug print this object. | |
Public Attributes | |
| PT | p0 |
| Start point. | |
| PT | p1 |
| End point. | |
| PT | normal |
| Normal but not normalized. | |
<TODO> Rewrite half-space storing only one point p0 and the normal.
Need to define zero. eg
template<> double zero<double>::val = 1E-15;
Definition at line 27 of file halfspaceD2.h.
| halfspaceD2< PT, PD >::halfspaceD2 | ( | ) | [inline] |
| halfspaceD2< PT, PD >::halfspaceD2 | ( | PT const & | p0_, | |
| PT const & | p1_ | |||
| ) | [inline] |
Construct a half space from the ordered points.
The normal is the line rotated 90 degrees anti clockwise.
Definition at line 44 of file halfspaceD2.h.
| boolc halfspaceD2< PT, PD >::clip | ( | PD & | t0, | |
| PD & | t1, | |||
| PT const & | a, | |||
| PT const & | m | |||
| ) | const [inline] |
Clip the line segment if cutting the half-space.
A false result rejects the line as it is outside the half-space. Line a+m*t with [t0,t1].
Definition at line 250 of file halfspaceD2.h.
Referenced by halfspaceD2test::unittest01().
00256 { 00257 int k=0; 00258 if (isInside(a+m*t0)) 00259 k += 1; 00260 if (isInside(a+m*t1)) 00261 k += 2; 00262 00263 switch (k) 00264 { 00265 case 0: return false; 00266 case 1: 00267 { 00268 point2<PD> t; 00269 if ( solver<PD>::d2linearequ(t,m,p0-p1,p0-a) == false ) 00270 return isInside(a); 00271 t1=t[0]; 00272 break; 00273 } 00274 case 2: 00275 { 00276 point2<PD> t; 00277 if ( solver<PD>::d2linearequ(t,m,p0-p1,p0-a) == false ) 00278 return isInside(a); 00279 t0=t[0]; 00280 break; 00281 } 00282 case 3: return true; 00283 } 00284 00285 return true; 00286 }
| boolc halfspaceD2< PT, PD >::clipNeg | ( | PD & | t0, | |
| PD & | t1, | |||
| PT const & | a, | |||
| PT const & | m | |||
| ) | const [inline] |
Invert the clip.
Definition at line 208 of file halfspaceD2.h.
Referenced by halfspaceD2test::unittest01().
00214 { 00215 00216 int k=0; 00217 if (!isInside(a+m*t0)) 00218 k += 1; 00219 if (!isInside(a+m*t1)) 00220 k += 2; 00221 00222 switch (k) 00223 { 00224 case 0: return false; 00225 case 1: 00226 { 00227 point2<PD> t; 00228 if ( solver<PD>::d2linearequ(t,m,p0-p1,p0-a) == false ) 00229 return !isInside(a); 00230 t1=t[0]; 00231 break; 00232 } 00233 case 2: 00234 { 00235 point2<PD> t; 00236 if ( solver<PD>::d2linearequ(t,m,p0-p1,p0-a) == false ) 00237 return !isInside(a); 00238 t0=t[0]; 00239 break; 00240 } 00241 case 3: return true; 00242 } 00243 00244 return true; 00245 }
| PD const halfspaceD2< PT, PD >::distancefromhalfspace | ( | PT const & | w | ) | const [inline] |
A measure of the minimum distance from the line to the point w without a square root.
Definition at line 148 of file halfspaceD2.h.
References halfspaceD2< PT, PD >::minimizepointtoline(), and halfspaceD2< PT, PD >::pointOnLine().
Referenced by halfspaceD2test::test02().
00149 { 00150 PD t; 00151 minimizepointtoline(t,w); 00152 PT w2; 00153 pointOnLine(w2,t); 00154 PT w3(w2.x-w.x,w2.y-w.y); 00155 return w3.x*w3.x+w3.y*w3.y; 00156 }
| boolc halfspaceD2< PT, PD >::intersection | ( | PT & | p, | |
| PT const & | a, | |||
| PT const & | b | |||
| ) | const [inline, virtual] |
Find the intersection of the line through (a,b) and this line.
Reimplemented from partitionspace< PT >.
Definition at line 170 of file halfspaceD2.h.
References d2matsolve().
Referenced by bsptreeD2dispregions01< PT, PD, INDX >::update().
00175 { 00176 PT const u(b-a); 00177 PT const v(p0-p1); 00178 PT const w(p0-a); 00179 // t0*u+t1*v=w 00180 PT t; 00181 bool res = d2matsolve(t,u,v,w); 00182 if (res==false) 00183 return false; 00184 00185 pointOnLine(p,t.y); 00186 00187 return true; 00188 }
| boolc halfspaceD2< PT, PD >::intersectionIn_t | ( | PT & | t, | |
| PT const & | a, | |||
| PT const & | b | |||
| ) | const [inline] |
Solve (t.x,t.y) : a+(-a+b)t.x = pointOnLine(t.y).
Definition at line 192 of file halfspaceD2.h.
References d2matsolve().
00197 { 00198 PT const u(b-a); 00199 PT const v(p0-p1); 00200 PT const w(p0-a); 00201 // t0*u+t1*v=w 00202 00203 return d2matsolve(t,u,v,w); 00204 }
| boolc halfspaceD2< PT, PD >::isInside | ( | PT const & | x | ) | const [inline, virtual] |
Is the point inside the half space?
Implements partitionspace< PT >.
Definition at line 63 of file halfspaceD2.h.
Referenced by d3tess::initialize(), d3tess::isconvex(), d3tess::move_terminated(), d2simplexSeparateAxis::sees(), d3tess::surfaceviewable(), and halfspaceD2test::test01().
| boolc halfspaceD2< PT, PD >::isInsideOrOnBoundary | ( | PT const & | x | ) | const [inline] |
Is the point on or inside the half space?
Definition at line 67 of file halfspaceD2.h.
Referenced by halfspaceD2test::test01().
00068 { return 0 < zero<PD>::val+(x.x-p0.x)*normal.x + (x.y-p0.y)*normal.y; }
| boolc halfspaceD2< PT, PD >::isOnBoundary | ( | PT const & | w | ) | const [inline, virtual] |
The client configures zero for the isOnBoundary routine.
Reimplemented from partitionspace< PT >.
Definition at line 99 of file halfspaceD2.h.
00100 { 00101 PD x = (p1.y-p0.y)*(w.x-p0.x) - (p1.x-p0.x)*(w.y-p0.y); 00102 if ( 0 < (x + zero<PD>::val) ) 00103 { 00104 if (x < zero<PD>::val) 00105 return true; 00106 } 00107 00108 return false; 00109 }
| void halfspaceD2< PT, PD >::minimizepointtoline | ( | PD & | t, | |
| PT const & | w | |||
| ) | const [inline] |
Find the nearest point on the line to w.
Definition at line 120 of file halfspaceD2.h.
Referenced by halfspaceD2< PT, PD >::distancefromhalfspace(), and halfspaceD2test::test02().
| void halfspaceD2< PT, PD >::normalcalculate | ( | ) | [inline] |
Calculate the normal the ordered points.
Definition at line 55 of file halfspaceD2.h.
Referenced by halfspaceD2draw::rotate(), halfspaceD2< PT, PD >::set(), and halfspaceD2draw::translate().
| halfspaceD2< PT, PD >::operator stringc | ( | ) | const [inline] |
| void halfspaceD2< PT, PD >::pointOnLine | ( | PT & | x, | |
| U const | t | |||
| ) | const [inline] |
Line [p0,p1] for t=[0,1].
Definition at line 74 of file halfspaceD2.h.
Referenced by halfspaceD2< PT, PD >::distancefromhalfspace(), and halfspaceD2test::test02().
| stringc halfspaceD2< PT, PD >::print | ( | ) | const [inline] |
| void halfspaceD2< PT, PD >::set | ( | PT const & | p0_, | |
| PT const & | p1_ | |||
| ) | [inline] |
Construct a half space from the ordered points.
Left of the directed line.
Definition at line 161 of file halfspaceD2.h.
References halfspaceD2< PT, PD >::normalcalculate(), halfspaceD2< PT, PD >::p0, and halfspaceD2< PT, PD >::p1.
Referenced by partitionstest::test03(), partitionstest::test04(), partitionstest::test05(), and trianglespace< T, D >::trianglespace().
00162 { 00163 p0 = p0_; 00164 p1 = p1_; 00165 normalcalculate(); 00166 }
| PT halfspaceD2< PT, PD >::normal |
Normal but not normalized.
Definition at line 36 of file halfspaceD2.h.
Referenced by halfspaceD2< T, D >::isInside(), halfspaceD2< T, D >::isInsideOrOnBoundary(), halfspaceD2< T, D >::normalcalculate(), halfspaceD2< T, D >::print(), and bsptreeD2dispregions01< PT, PD, INDX >::update().
| PT halfspaceD2< PT, PD >::p0 |
Start point.
Definition at line 32 of file halfspaceD2.h.
Referenced by halfspaceD2draw::alphacalculate(), halfspaceD2draw::draw(), halfspaceD2< T, D >::isInside(), halfspaceD2< T, D >::isInsideOrOnBoundary(), halfspaceD2< T, D >::isOnBoundary(), halfspaceD2< T, D >::minimizepointtoline(), halfspaceD2< T, D >::normalcalculate(), halfspaceD2< T, D >::operator stringc(), halfspaceD2< T, D >::pointOnLine(), halfspaceD2< T, D >::print(), halfspaceD2draw::rotate(), halfspaceD2< PT, PD >::set(), halfspaceD2draw::translate(), bsptreeD2dispregions01< PT, PD, INDX >::update(), bsptreeD2disp03< PT, PD, INDX >::update(), bsptreeD2disp02< PT, PD, INDX >::update(), bsptreeD2disp01< PT, PD, INDX >::update(), and bsptreeD2< PT, PD, INDX >::validhalfspaces().
| PT halfspaceD2< PT, PD >::p1 |
End point.
Definition at line 34 of file halfspaceD2.h.
Referenced by halfspaceD2draw::alphacalculate(), halfspaceD2draw::draw(), halfspaceD2< T, D >::isOnBoundary(), halfspaceD2< T, D >::minimizepointtoline(), halfspaceD2< T, D >::normalcalculate(), halfspaceD2< T, D >::operator stringc(), halfspaceD2< T, D >::pointOnLine(), halfspaceD2< T, D >::print(), halfspaceD2draw::rotate(), halfspaceD2< PT, PD >::set(), halfspaceD2draw::translate(), bsptreeD2dispregions01< PT, PD, INDX >::update(), bsptreeD2disp03< PT, PD, INDX >::update(), bsptreeD2disp02< PT, PD, INDX >::update(), bsptreeD2disp01< PT, PD, INDX >::update(), and bsptreeD2< PT, PD, INDX >::validhalfspaces().
1.5.8