cd_vector.h
Go to the documentation of this file.
1 #ifndef CD_VECTOR_H
2 
3 #define CD_VECTOR_H
4 
61 // http://codesuppository.blogspot.com
62 //
63 // mailto: jratcliff@infiniplex.net
64 //
65 // http://www.amillionpixels.us
66 //
67 
68 
69 #pragma warning(disable:4786)
70 
71 #include <math.h>
72 #include <float.h>
73 #include <vector>
74 
75 namespace ConvexDecomposition
76 {
77 
78 
79 const double DEG_TO_RAD = ((2.0f * 3.14152654f) / 360.0f);
80 const double RAD_TO_DEG = (360.0f / (2.0f * 3.141592654f));
81 
82 template <class Type> class Vector3d
83 {
84 public:
85  Vector3d(void) { }; // null constructor, does not inialize point.
86 
87  Vector3d(const Vector3d &a) // constructor copies existing vector.
88  {
89  x = a.x;
90  y = a.y;
91  z = a.z;
92  };
93 
94  Vector3d(Type a,Type b,Type c) // construct with initial point.
95  {
96  x = a;
97  y = b;
98  z = c;
99  };
100 
101  Vector3d(const double *t)
102  {
103  x = t[0];
104  y = t[1];
105  z = t[2];
106  };
107 
108  Vector3d(const int *t)
109  {
110  x = t[0];
111  y = t[1];
112  z = t[2];
113  };
114 
115  bool operator==(const Vector3d<Type> &a) const
116  {
117  return( a.x == x && a.y == y && a.z == z );
118  };
119 
120  bool operator!=(const Vector3d<Type> &a) const
121  {
122  return( a.x != x || a.y != y || a.z != z );
123  };
124 
125 // Operators
126  Vector3d& operator = (const Vector3d& A) // ASSIGNMENT (=)
127  { x=A.x; y=A.y; z=A.z;
128  return(*this); };
129 
130  Vector3d operator + (const Vector3d& A) const // ADDITION (+)
131  { Vector3d Sum(x+A.x, y+A.y, z+A.z);
132  return(Sum); };
133 
134  Vector3d operator - (const Vector3d& A) const // SUBTRACTION (-)
135  { Vector3d Diff(x-A.x, y-A.y, z-A.z);
136  return(Diff); };
137 
138  Vector3d operator * (const double s) const // MULTIPLY BY SCALAR (*)
139  { Vector3d Scaled(x*s, y*s, z*s);
140  return(Scaled); };
141 
142 
143  Vector3d operator + (const double s) const // ADD CONSTANT TO ALL 3 COMPONENTS (*)
144  { Vector3d Scaled(x+s, y+s, z+s);
145  return(Scaled); };
146 
147 
148 
149 
150  Vector3d operator / (const double s) const // DIVIDE BY SCALAR (/)
151  {
152  double r = 1.0f / s;
153  Vector3d Scaled(x*r, y*r, z*r);
154  return(Scaled);
155  };
156 
157  void operator /= (Type A) // ACCUMULATED VECTOR ADDITION (/=)
158  { x/=A; y/=A; z/=A; };
159 
160  void operator += (const Vector3d A) // ACCUMULATED VECTOR ADDITION (+=)
161  { x+=A.x; y+=A.y; z+=A.z; };
162  void operator -= (const Vector3d A) // ACCUMULATED VECTOR SUBTRACTION (+=)
163  { x-=A.x; y-=A.y; z-=A.z; };
164  void operator *= (const double s) // ACCUMULATED SCALAR MULTIPLICATION (*=) (bpc 4/24/2000)
165  {x*=s; y*=s; z*=s;}
166 
167  void operator += (const double A) // ACCUMULATED VECTOR ADDITION (+=)
168  { x+=A; y+=A; z+=A; };
169 
170 
171  Vector3d operator - (void) const // NEGATION (-)
172  { Vector3d Negated(-x, -y, -z);
173  return(Negated); };
174 
175  Type operator [] (const int i) const // ALLOWS VECTOR ACCESS AS AN ARRAY.
176  { return( (i==0)?x:((i==1)?y:z) ); };
177  Type & operator [] (const int i)
178  { return( (i==0)?x:((i==1)?y:z) ); };
179 //
180 
181  // accessor methods.
182  Type GetX(void) const { return x; };
183  Type GetY(void) const { return y; };
184  Type GetZ(void) const { return z; };
185 
186  Type X(void) const { return x; };
187  Type Y(void) const { return y; };
188  Type Z(void) const { return z; };
189 
190  void SetX(Type t) { x = t; };
191  void SetY(Type t) { y = t; };
192  void SetZ(Type t) { z = t; };
193 
194  bool IsSame(const Vector3d<double> &v,double epsilon) const
195  {
196  double dx = fabsf( x - v.x );
197  if ( dx > epsilon ) return false;
198  double dy = fabsf( y - v.y );
199  if ( dy > epsilon ) return false;
200  double dz = fabsf( z - v.z );
201  if ( dz > epsilon ) return false;
202  return true;
203  }
204 
205 
207  const Vector3d<double> &B,
208  const Vector3d<double> &C)
209  {
210  double vx,vy,vz,wx,wy,wz,vw_x,vw_y,vw_z,mag;
211 
212  vx = (B.x - C.x);
213  vy = (B.y - C.y);
214  vz = (B.z - C.z);
215 
216  wx = (A.x - B.x);
217  wy = (A.y - B.y);
218  wz = (A.z - B.z);
219 
220  vw_x = vy * wz - vz * wy;
221  vw_y = vz * wx - vx * wz;
222  vw_z = vx * wy - vy * wx;
223 
224  mag = sqrtf((vw_x * vw_x) + (vw_y * vw_y) + (vw_z * vw_z));
225 
226  if ( mag < 0.000001f )
227  {
228  mag = 0;
229  }
230  else
231  {
232  mag = 1.0f/mag;
233  }
234 
235  x = vw_x * mag;
236  y = vw_y * mag;
237  z = vw_z * mag;
238 
239  return mag;
240  }
241 
242 
243  void ScaleSumScale(double c0,double c1,const Vector3d<double> &pos)
244  {
245  x = (x*c0) + (pos.x*c1);
246  y = (y*c0) + (pos.y*c1);
247  z = (z*c0) + (pos.z*c1);
248  }
249 
250  void SwapYZ(void)
251  {
252  double t = y;
253  y = z;
254  z = t;
255  };
256 
257  void Get(Type *v) const
258  {
259  v[0] = x;
260  v[1] = y;
261  v[2] = z;
262  };
263 
264  void Set(const int *p)
265  {
266  x = (Type) p[0];
267  y = (Type) p[1];
268  z = (Type) p[2];
269  }
270 
271  void Set(const double *p)
272  {
273  x = (Type) p[0];
274  y = (Type) p[1];
275  z = (Type) p[2];
276  }
277 
278 
279  void Set(Type a,Type b,Type c)
280  {
281  x = a;
282  y = b;
283  z = c;
284  };
285 
286  void Zero(void)
287  {
288  x = y = z = 0;
289  };
290 
291  const Type* Ptr() const { return &x; }
292  Type* Ptr() { return &x; }
293 
294 
295 // return -(*this).
296  Vector3d negative(void) const
297  {
298  Vector3d result;
299  result.x = -x;
300  result.y = -y;
301  result.z = -z;
302  return result;
303  }
304 
305  Type Magnitude(void) const
306  {
307  return Type(sqrt(x * x + y * y + z * z));
308  };
309 
310  Type FastMagnitude(void) const
311  {
312  return Type(sqrt(x * x + y * y + z * z));
313  };
314 
315  Type FasterMagnitude(void) const
316  {
317  return Type(sqrt(x * x + y * y + z * z));
318  };
319 
320  void Lerp(const Vector3d<Type>& from,const Vector3d<Type>& to,double slerp)
321  {
322  x = ((to.x - from.x) * slerp) + from.x;
323  y = ((to.y - from.y) * slerp) + from.y;
324  z = ((to.z - from.z) * slerp) + from.z;
325  };
326 
327  // Highly specialized interpolate routine. Will compute the interpolated position
328  // shifted forward or backwards along the ray defined between (from) and (to).
329  // Reason for existance is so that when a bullet collides with a wall, for
330  // example, you can generate a graphic effect slightly *before* it hit the
331  // wall so that the effect doesn't sort into the wall itself.
332  void Interpolate(const Vector3d<double> &from,const Vector3d<double> &to,double offset)
333  {
334  x = to.x-from.x;
335  y = to.y-from.y;
336  z = to.z-from.z;
337  double d = sqrtf( x*x + y*y + z*z );
338  double recip = 1.0f / d;
339  x*=recip;
340  y*=recip;
341  z*=recip; // normalize vector
342  d+=offset; // shift along ray
343  x = x*d + from.x;
344  y = y*d + from.y;
345  z = z*d + from.z;
346  };
347 
348  bool BinaryEqual(const Vector3d<double> &p) const
349  {
350  const int *source = (const int *) &x;
351  const int *dest = (const int *) &p.x;
352 
353  if ( source[0] == dest[0] &&
354  source[1] == dest[1] &&
355  source[2] == dest[2] ) return true;
356 
357  return false;
358  };
359 
360  bool BinaryEqual(const Vector3d<int> &p) const
361  {
362  if ( x == p.x && y == p.y && z == p.z ) return true;
363  return false;
364  }
365 
366 
368  void Reflection(const Vector3d<Type> &a,const Vector3d<Type> &b)// compute reflection vector.
369  {
372 
373  double dot = a.Dot(b) * 2.0f;
374 
375  c = b * dot;
376 
377  d = c - a;
378 
379  x = -d.x;
380  y = -d.y;
381  z = -d.z;
382  };
383 
384  void AngleAxis(Type angle,const Vector3d<Type>& axis)
385  {
386  x = axis.x*angle;
387  y = axis.y*angle;
388  z = axis.z*angle;
389  };
390 
391  Type Length(void) const // length of vector.
392  {
393  return Type(sqrt( x*x + y*y + z*z ));
394  };
395 
396 
398  const Vector3d<double> &B,
399  const Vector3d<double> &C)
400  {
401  double vx,vy,vz,wx,wy,wz,vw_x,vw_y,vw_z,mag;
402 
403  vx = (B.x - C.x);
404  vy = (B.y - C.y);
405  vz = (B.z - C.z);
406 
407  wx = (A.x - B.x);
408  wy = (A.y - B.y);
409  wz = (A.z - B.z);
410 
411  vw_x = vy * wz - vz * wy;
412  vw_y = vz * wx - vx * wz;
413  vw_z = vx * wy - vy * wx;
414 
415  mag = sqrt((vw_x * vw_x) + (vw_y * vw_y) + (vw_z * vw_z));
416 
417  if ( mag < 0.000001f )
418  {
419  mag = 0;
420  }
421  else
422  {
423  mag = 1.0f/mag;
424  }
425 
426  x = vw_x * mag;
427  y = vw_y * mag;
428  z = vw_z * mag;
429 
430 
431  double D = 0.0f - ((x*A.x)+(y*A.y)+(z*A.z));
432 
433  return D;
434  }
435 
436 
437  Type FastLength(void) const // length of vector.
438  {
439  return Type(sqrt( x*x + y*y + z*z ));
440  };
441 
442 
443  Type FasterLength(void) const // length of vector.
444  {
445  return Type(sqrt( x*x + y*y + z*z ));
446  };
447 
448  Type Length2(void) const // squared distance, prior to square root.
449  {
450  Type l2 = x*x+y*y+z*z;
451  return l2;
452  };
453 
454  Type Distance(const Vector3d<Type> &a) const // distance between two points.
455  {
456  Vector3d<Type> d(a.x-x,a.y-y,a.z-z);
457  return d.Length();
458  }
459 
460  Type FastDistance(const Vector3d<Type> &a) const // distance between two points.
461  {
462  Vector3d<Type> d(a.x-x,a.y-y,a.z-z);
463  return d.FastLength();
464  }
465 
466  Type FasterDistance(const Vector3d<Type> &a) const // distance between two points.
467  {
468  Vector3d<Type> d(a.x-x,a.y-y,a.z-z);
469  return d.FasterLength();
470  }
471 
472 
473  Type DistanceXY(const Vector3d<Type> &a) const
474  {
475  double dx = a.x - x;
476  double dy = a.y - y;
477  double dist = dx*dx + dy*dy;
478  return dist;
479  }
480 
481  Type Distance2(const Vector3d<Type> &a) const // squared distance.
482  {
483  double dx = a.x - x;
484  double dy = a.y - y;
485  double dz = a.z - z;
486  return dx*dx + dy*dy + dz*dz;
487  };
488 
489  Type Partial(const Vector3d<Type> &p) const
490  {
491  return (x*p.y) - (p.x*y);
492  }
493 
494  Type Area(const Vector3d<Type> &p1,const Vector3d<Type> &p2) const
495  {
496  Type A = Partial(p1);
497  A+= p1.Partial(p2);
498  A+= p2.Partial(*this);
499  return A*0.5f;
500  }
501 
502  inline double Normalize(void) // normalize to a unit vector, returns distance.
503  {
504  double d = sqrtf( static_cast< double >( x*x + y*y + z*z ) );
505  if ( d > 0 )
506  {
507  double r = 1.0f / d;
508  x *= r;
509  y *= r;
510  z *= r;
511  }
512  else
513  {
514  x = y = z = 1;
515  }
516  return d;
517  };
518 
519  inline double FastNormalize(void) // normalize to a unit vector, returns distance.
520  {
521  double d = sqrt( static_cast< double >( x*x + y*y + z*z ) );
522  if ( d > 0 )
523  {
524  double r = 1.0f / d;
525  x *= r;
526  y *= r;
527  z *= r;
528  }
529  else
530  {
531  x = y = z = 1;
532  }
533  return d;
534  };
535 
536  inline double FasterNormalize(void) // normalize to a unit vector, returns distance.
537  {
538  double d = sqrt( static_cast< double >( x*x + y*y + z*z ) );
539  if ( d > 0 )
540  {
541  double r = 1.0f / d;
542  x *= r;
543  y *= r;
544  z *= r;
545  }
546  else
547  {
548  x = y = z = 1;
549  }
550  return d;
551  };
552 
553 
554 
555 
556  Type Dot(const Vector3d<Type> &a) const // computes dot product.
557  {
558  return (x * a.x + y * a.y + z * a.z );
559  };
560 
561 
562  Vector3d<Type> Cross( const Vector3d<Type>& other ) const
563  {
564  Vector3d<Type> result( y*other.z - z*other.y, z*other.x - x*other.z, x*other.y - y*other.x );
565 
566  return result;
567  }
568 
569  void Cross(const Vector3d<Type> &a,const Vector3d<Type> &b) // cross two vectors result in this one.
570  {
571  x = a.y*b.z - a.z*b.y;
572  y = a.z*b.x - a.x*b.z;
573  z = a.x*b.y - a.y*b.x;
574  };
575 
576  /******************************************/
577  // Check if next edge (b to c) turns inward
578  //
579  // Edge from a to b is already in face
580  // Edge from b to c is being considered for addition to face
581  /******************************************/
582  bool Concave(const Vector3d<double>& a,const Vector3d<double>& b)
583  {
584  double vx,vy,vz,wx,wy,wz,vw_x,vw_y,vw_z,mag,nx,ny,nz,mag_a,mag_b;
585 
586  wx = b.x - a.x;
587  wy = b.y - a.y;
588  wz = b.z - a.z;
589 
590  mag_a = (double) sqrtf((wx * wx) + (wy * wy) + (wz * wz));
591 
592  vx = x - b.x;
593  vy = y - b.y;
594  vz = z - b.z;
595 
596  mag_b = (double) sqrtf((vx * vx) + (vy * vy) + (vz * vz));
597 
598  vw_x = (vy * wz) - (vz * wy);
599  vw_y = (vz * wx) - (vx * wz);
600  vw_z = (vx * wy) - (vy * wx);
601 
602  mag = (double) sqrtf((vw_x * vw_x) + (vw_y * vw_y) + (vw_z * vw_z));
603 
604  // Check magnitude of cross product, which is a sine function
605  // i.e., mag (a x b) = mag (a) * mag (b) * sin (theta);
606  // If sin (theta) small, then angle between edges is very close to
607  // 180, which we may want to call a concavity. Setting the
608  // CONCAVITY_TOLERANCE value greater than about 0.01 MAY cause
609  // face consolidation to get stuck on particular face. Most meshes
610  // convert properly with a value of 0.0
611 
612  if (mag/(mag_a*mag_b) <= 0.0f ) return true;
613 
614  mag = 1.0f / mag;
615 
616  nx = vw_x * mag;
617  ny = vw_y * mag;
618  nz = vw_z * mag;
619 
620  // Dot product of tri normal with cross product result will
621  // yield positive number if edges are convex (+1.0 if two tris
622  // are coplanar), negative number if edges are concave (-1.0 if
623  // two tris are coplanar.)
624 
625  mag = ( x * nx) + ( y * ny) + ( z * nz);
626 
627  if (mag > 0.0f ) return false;
628 
629  return(true);
630  };
631 
632  bool PointTestXY(const Vector3d<double> &i,const Vector3d<double> &j) const
633  {
634  if (((( i.y <= y ) && ( y < j.y )) ||
635  (( j.y <= y ) && ( y < i.y ))) &&
636  ( x < (j.x - i.x) * (y - i.y) / (j.y - i.y) + i.x)) return true;
637  return false;
638  }
639 
640  // test to see if this point is inside the triangle specified by
641  // these three points on the X/Y plane.
643  const Vector3d<double> &p2,
644  const Vector3d<double> &p3) const
645  {
646  double ax = p3.x - p2.x;
647  double ay = p3.y - p2.y;
648  double bx = p1.x - p3.x;
649  double by = p1.y - p3.y;
650  double cx = p2.x - p1.x;
651  double cy = p2.y - p1.y;
652  double apx = x - p1.x;
653  double apy = y - p1.y;
654  double bpx = x - p2.x;
655  double bpy = y - p2.y;
656  double cpx = x - p3.x;
657  double cpy = y - p3.y;
658 
659  double aCROSSbp = ax*bpy - ay*bpx;
660  double cCROSSap = cx*apy - cy*apx;
661  double bCROSScp = bx*cpy - by*cpx;
662 
663  return ((aCROSSbp >= 0.0f) && (bCROSScp >= 0.0f) && (cCROSSap >= 0.0f));
664  };
665 
666  // test to see if this point is inside the triangle specified by
667  // these three points on the X/Y plane.
669  const Vector3d<double> &p2,
670  const Vector3d<double> &p3) const
671  {
672  double ay = p3.y - p2.y;
673  double az = p3.z - p2.z;
674  double by = p1.y - p3.y;
675  double bz = p1.z - p3.z;
676  double cy = p2.y - p1.y;
677  double cz = p2.z - p1.z;
678  double apy = y - p1.y;
679  double apz = z - p1.z;
680  double bpy = y - p2.y;
681  double bpz = z - p2.z;
682  double cpy = y - p3.y;
683  double cpz = z - p3.z;
684 
685  double aCROSSbp = ay*bpz - az*bpy;
686  double cCROSSap = cy*apz - cz*apy;
687  double bCROSScp = by*cpz - bz*cpy;
688 
689  return ((aCROSSbp >= 0.0f) && (bCROSScp >= 0.0f) && (cCROSSap >= 0.0f));
690  };
691 
692 
693  // test to see if this point is inside the triangle specified by
694  // these three points on the X/Y plane.
696  const Vector3d<double> &p2,
697  const Vector3d<double> &p3) const
698  {
699  double az = p3.z - p2.z;
700  double ax = p3.x - p2.x;
701  double bz = p1.z - p3.z;
702  double bx = p1.x - p3.x;
703  double cz = p2.z - p1.z;
704  double cx = p2.x - p1.x;
705  double apz = z - p1.z;
706  double apx = x - p1.x;
707  double bpz = z - p2.z;
708  double bpx = x - p2.x;
709  double cpz = z - p3.z;
710  double cpx = x - p3.x;
711 
712  double aCROSSbp = az*bpx - ax*bpz;
713  double cCROSSap = cz*apx - cx*apz;
714  double bCROSScp = bz*cpx - bx*cpz;
715 
716  return ((aCROSSbp >= 0.0f) && (bCROSScp >= 0.0f) && (cCROSSap >= 0.0f));
717  };
718 
719  // Given a point and a line (defined by two points), compute the closest point
720  // in the line. (The line is treated as infinitely long.)
722  const Vector3d<Type> &line0,
723  const Vector3d<Type> &line1)
724  {
725  Vector3d<Type> &nearestPoint = *this;
726  Vector3d<Type> lineDelta = line1 - line0;
727 
728  // Handle degenerate lines
729  if ( lineDelta == Vector3d<Type>(0, 0, 0) )
730  {
731  nearestPoint = line0;
732  }
733  else
734  {
735  double delta = (point-line0).Dot(lineDelta) / (lineDelta).Dot(lineDelta);
736  nearestPoint = line0 + delta*lineDelta;
737  }
738  }
739 
740  // Given a point and a line segment (defined by two points), compute the closest point
741  // in the line. Cap the point at the endpoints of the line segment.
743  const Vector3d<Type> &line0,
744  const Vector3d<Type> &line1)
745  {
746  Vector3d<Type> &nearestPoint = *this;
747  Vector3d<Type> lineDelta = line1 - line0;
748 
749  // Handle degenerate lines
750  if ( lineDelta == Vector3d<double>(0, 0, 0) )
751  {
752  nearestPoint = line0;
753  }
754  else
755  {
756  double delta = (point-line0).Dot(lineDelta) / (lineDelta).Dot(lineDelta);
757 
758  // Clamp the point to conform to the segment's endpoints
759  if ( delta < 0 )
760  delta = 0;
761  else if ( delta > 1 )
762  delta = 1;
763 
764  nearestPoint = line0 + delta*lineDelta;
765  }
766  }
767 
768  // Given a point and a plane (defined by three points), compute the closest point
769  // in the plane. (The plane is unbounded.)
771  const Vector3d<Type> &triangle0,
772  const Vector3d<Type> &triangle1,
773  const Vector3d<Type> &triangle2)
774  {
775  Vector3d<Type> &nearestPoint = *this;
776  Vector3d<Type> lineDelta0 = triangle1 - triangle0;
777  Vector3d<Type> lineDelta1 = triangle2 - triangle0;
778  Vector3d<Type> pointDelta = point - triangle0;
779  Vector3d<Type> normal;
780 
781  // Get the normal of the polygon (doesn't have to be a unit vector)
782  normal.Cross(lineDelta0, lineDelta1);
783 
784  double delta = normal.Dot(pointDelta) / normal.Dot(normal);
785  nearestPoint = point - delta*normal;
786  }
787 
788  // Given a point and a plane (defined by a coplanar point and a normal), compute the closest point
789  // in the plane. (The plane is unbounded.)
791  const Vector3d<Type> &planePoint,
792  const Vector3d<Type> &planeNormal)
793  {
794  Vector3d<Type> &nearestPoint = *this;
795  Vector3d<Type> pointDelta = point - planePoint;
796 
797  double delta = planeNormal.Dot(pointDelta) / planeNormal.Dot(planeNormal);
798  nearestPoint = point - delta*planeNormal;
799  }
800 
801  // Given a point and a triangle (defined by three points), compute the closest point
802  // in the triangle. Clamp the point so it's confined to the area of the triangle.
804  const Vector3d<Type> &triangle0,
805  const Vector3d<Type> &triangle1,
806  const Vector3d<Type> &triangle2)
807  {
808  static const Vector3d<Type> zeroVector(0, 0, 0);
809 
810  Vector3d<Type> &nearestPoint = *this;
811 
812  Vector3d<Type> lineDelta0 = triangle1 - triangle0;
813  Vector3d<Type> lineDelta1 = triangle2 - triangle0;
814 
815  // Handle degenerate triangles
816  if ( (lineDelta0 == zeroVector) || (lineDelta1 == zeroVector) )
817  {
818  nearestPoint.NearestPointInLineSegment(point, triangle1, triangle2);
819  }
820  else if ( lineDelta0 == lineDelta1 )
821  {
822  nearestPoint.NearestPointInLineSegment(point, triangle0, triangle1);
823  }
824 
825  else
826  {
827  static Vector3d<Type> axis[3];
828  axis[0].NearestPointInLine(triangle0, triangle1, triangle2);
829  axis[1].NearestPointInLine(triangle1, triangle0, triangle2);
830  axis[2].NearestPointInLine(triangle2, triangle0, triangle1);
831 
832  Type axisDot[3];
833  axisDot[0] = (triangle0-axis[0]).Dot(point-axis[0]);
834  axisDot[1] = (triangle1-axis[1]).Dot(point-axis[1]);
835  axisDot[2] = (triangle2-axis[2]).Dot(point-axis[2]);
836 
837  bool bForce = true;
838  Type bestMagnitude2 = 0;
839  Type closeMagnitude2;
840  Vector3d<double> closePoint;
841 
842  if ( axisDot[0] < 0 )
843  {
844  closePoint.NearestPointInLineSegment(point, triangle1, triangle2);
845  closeMagnitude2 = point.Distance2(closePoint);
846  if ( bForce || (bestMagnitude2 > closeMagnitude2) )
847  {
848  bForce = false;
849  bestMagnitude2 = closeMagnitude2;
850  nearestPoint = closePoint;
851  }
852  }
853  if ( axisDot[1] < 0 )
854  {
855  closePoint.NearestPointInLineSegment(point, triangle0, triangle2);
856  closeMagnitude2 = point.Distance2(closePoint);
857  if ( bForce || (bestMagnitude2 > closeMagnitude2) )
858  {
859  bForce = false;
860  bestMagnitude2 = closeMagnitude2;
861  nearestPoint = closePoint;
862  }
863  }
864  if ( axisDot[2] < 0 )
865  {
866  closePoint.NearestPointInLineSegment(point, triangle0, triangle1);
867  closeMagnitude2 = point.Distance2(closePoint);
868  if ( bForce || (bestMagnitude2 > closeMagnitude2) )
869  {
870  bForce = false;
871  bestMagnitude2 = closeMagnitude2;
872  nearestPoint = closePoint;
873  }
874  }
875 
876  // If bForce is true at this point, it means the nearest point lies
877  // inside the triangle; use the nearest-point-on-a-plane equation
878  if ( bForce )
879  {
880  Vector3d<Type> normal;
881 
882  // Get the normal of the polygon (doesn't have to be a unit vector)
883  normal.Cross(lineDelta0, lineDelta1);
884 
885  Vector3d<double> pointDelta = point - triangle0;
886  double delta = normal.Dot(pointDelta) / normal.Dot(normal);
887 
888  nearestPoint = point - delta*normal;
889  }
890  }
891  }
892 
893 
894 //private:
895 
896  Type x;
897  Type y;
898  Type z;
899 };
900 
901 
902 template <class Type> class Vector2d
903 {
904 public:
905  Vector2d(void) { }; // null constructor, does not inialize point.
906 
907  Vector2d(const Vector2d &a) // constructor copies existing vector.
908  {
909  x = a.x;
910  y = a.y;
911  };
912 
913  Vector2d(const double *t)
914  {
915  x = t[0];
916  y = t[1];
917  };
918 
919 
920  Vector2d(Type a,Type b) // construct with initial point.
921  {
922  x = a;
923  y = b;
924  };
925 
926  const Type* Ptr() const { return &x; }
927  Type* Ptr() { return &x; }
928 
929  Vector2d & operator+=(const Vector2d &a) // += operator.
930  {
931  x+=a.x;
932  y+=a.y;
933  return *this;
934  };
935 
937  {
938  x-=a.x;
939  y-=a.y;
940  return *this;
941  };
942 
944  {
945  x*=a.x;
946  y*=a.y;
947  return *this;
948  };
949 
951  {
952  x/=a.x;
953  y/=a.y;
954  return *this;
955  };
956 
957  bool operator==(const Vector2d<Type> &a) const
958  {
959  if ( a.x == x && a.y == y ) return true;
960  return false;
961  };
962 
963  bool operator!=(const Vector2d &a) const
964  {
965  if ( a.x != x || a.y != y ) return true;
966  return false;
967  };
968 
970  {
971  a.x+=x;
972  a.y+=y;
973  return a;
974  };
975 
977  {
978  a.x = x-a.x;
979  a.y = y-a.y;
980  return a;
981  };
982 
983  Vector2d operator - (void) const
984  {
985  return negative();
986  };
987 
989  {
990  a.x*=x;
991  a.y*=y;
992  return a;
993  };
994 
995  Vector2d operator*(Type c) const
996  {
997  Vector2d<Type> a;
998 
999  a.x = x * c;
1000  a.y = y * c;
1001 
1002  return a;
1003  };
1004 
1006  {
1007  a.x = x/a.x;
1008  a.y = y/a.y;
1009  return a;
1010  };
1011 
1012 
1013  Type Dot(const Vector2d<Type> &a) const // computes dot product.
1014  {
1015  return (x * a.x + y * a.y );
1016  };
1017 
1018  Type GetX(void) const { return x; };
1019  Type GetY(void) const { return y; };
1020 
1021  void SetX(Type t) { x = t; };
1022  void SetY(Type t) { y = t; };
1023 
1024  void Set(Type a,Type b)
1025  {
1026  x = a;
1027  y = b;
1028  };
1029 
1030  void Zero(void)
1031  {
1032  x = 0;
1033  y = 0;
1034  };
1035 
1036  Vector2d negative(void) const
1037  {
1038  Vector2d result;
1039  result.x = -x;
1040  result.y = -y;
1041  return result;
1042  }
1043 
1044  Type magnitude(void) const
1045  {
1046  return (Type) sqrtf(x * x + y * y );
1047  }
1048 
1049  Type fastmagnitude(void) const
1050  {
1051  return (Type) sqrt(x * x + y * y );
1052  }
1053 
1054  Type fastermagnitude(void) const
1055  {
1056  return (Type) sqrt( x * x + y * y );
1057  }
1058 
1059  void Reflection(Vector2d &a,Vector2d &b); // compute reflection vector.
1060 
1061  Type Length(void) const // length of vector.
1062  {
1063  return Type(sqrtf( x*x + y*y ));
1064  };
1065 
1066  Type FastLength(void) const // length of vector.
1067  {
1068  return Type(sqrt( x*x + y*y ));
1069  };
1070 
1071  Type FasterLength(void) const // length of vector.
1072  {
1073  return Type(sqrt( x*x + y*y ));
1074  };
1075 
1076  Type Length2(void) // squared distance, prior to square root.
1077  {
1078  return x*x+y*y;
1079  }
1080 
1081  Type Distance(const Vector2d &a) const // distance between two points.
1082  {
1083  Type dx = a.x - x;
1084  Type dy = a.y - y;
1085  Type d = dx*dx+dy*dy;
1086  return sqrtf(d);
1087  };
1088 
1089  Type FastDistance(const Vector2d &a) const // distance between two points.
1090  {
1091  Type dx = a.x - x;
1092  Type dy = a.y - y;
1093  Type d = dx*dx+dy*dy;
1094  return sqrt(d);
1095  };
1096 
1097  Type FasterDistance(const Vector2d &a) const // distance between two points.
1098  {
1099  Type dx = a.x - x;
1100  Type dy = a.y - y;
1101  Type d = dx*dx+dy*dy;
1102  return sqrt(d);
1103  };
1104 
1105  Type Distance2(Vector2d &a) // squared distance.
1106  {
1107  Type dx = a.x - x;
1108  Type dy = a.y - y;
1109  return dx*dx + dy *dy;
1110  };
1111 
1112  void Lerp(const Vector2d<Type>& from,const Vector2d<Type>& to,double slerp)
1113  {
1114  x = ((to.x - from.x)*slerp) + from.x;
1115  y = ((to.y - from.y)*slerp) + from.y;
1116  };
1117 
1118 
1119  void Cross(const Vector2d<Type> &a,const Vector2d<Type> &b) // cross two vectors result in this one.
1120  {
1121  x = a.y*b.x - a.x*b.y;
1122  y = a.x*b.x - a.x*b.x;
1123  };
1124 
1125  Type Normalize(void) // normalize to a unit vector, returns distance.
1126  {
1127  Type l = Length();
1128  if ( l != 0 )
1129  {
1130  l = Type( 1 ) / l;
1131  x*=l;
1132  y*=l;
1133  }
1134  else
1135  {
1136  x = y = 0;
1137  }
1138  return l;
1139  };
1140 
1141  Type FastNormalize(void) // normalize to a unit vector, returns distance.
1142  {
1143  Type l = FastLength();
1144  if ( l != 0 )
1145  {
1146  l = Type( 1 ) / l;
1147  x*=l;
1148  y*=l;
1149  }
1150  else
1151  {
1152  x = y = 0;
1153  }
1154  return l;
1155  };
1156 
1157  Type FasterNormalize(void) // normalize to a unit vector, returns distance.
1158  {
1159  Type l = FasterLength();
1160  if ( l != 0 )
1161  {
1162  l = Type( 1 ) / l;
1163  x*=l;
1164  y*=l;
1165  }
1166  else
1167  {
1168  x = y = 0;
1169  }
1170  return l;
1171  };
1172 
1173 
1174  Type x;
1175  Type y;
1176 };
1177 
1178 class Line
1179 {
1180 public:
1181  Line(const Vector3d<double> &from,const Vector3d<double> &to)
1182  {
1183  mP1 = from;
1184  mP2 = to;
1185  };
1186  // JWR Test for the intersection of two lines.
1187 
1188  bool Intersect(const Line& src,Vector3d<double> &sect);
1189 private:
1192 
1193 };
1194 
1195 
1196 typedef std::vector< Vector3d<double> > Vector3dVector;
1197 typedef std::vector< Vector2d<double> > Vector2dVector;
1198 
1199 template <class Type> Vector3d<Type> operator * (Type s, const Vector3d<Type> &v )
1200  { Vector3d <Type> Scaled(v.x*s, v.y*s, v.z*s);
1201  return(Scaled); };
1202 
1203 template <class Type> Vector2d<Type> operator * (Type s, const Vector2d<Type> &v )
1204  { Vector2d <Type> Scaled(v.x*s, v.y*s);
1205  return(Scaled); };
1206 
1207 };
1208 
1209 #endif
ConvexDecomposition::Vector3d
Definition: cd_vector.h:82
ConvexDecomposition::Vector3d::Vector3d
Vector3d(const Vector3d &a)
Definition: cd_vector.h:87
ConvexDecomposition::Vector2d::Ptr
const Type * Ptr() const
Definition: cd_vector.h:926
ConvexDecomposition::Vector2d::Distance2
Type Distance2(Vector2d &a)
Definition: cd_vector.h:1105
ConvexDecomposition::Vector3d::ScaleSumScale
void ScaleSumScale(double c0, double c1, const Vector3d< double > &pos)
Definition: cd_vector.h:243
ConvexDecomposition::Vector3d::Partial
Type Partial(const Vector3d< Type > &p) const
Definition: cd_vector.h:489
ConvexDecomposition::Vector3d::Distance
Type Distance(const Vector3d< Type > &a) const
Definition: cd_vector.h:454
ConvexDecomposition::Vector3d::Y
Type Y(void) const
Definition: cd_vector.h:187
ConvexDecomposition::Vector3d::Vector3d
Vector3d(Type a, Type b, Type c)
Definition: cd_vector.h:94
ConvexDecomposition::Vector3d::y
Type y
Definition: cd_vector.h:897
ConvexDecomposition::Vector2d::Ptr
Type * Ptr()
Definition: cd_vector.h:927
ConvexDecomposition::Vector3d::BinaryEqual
bool BinaryEqual(const Vector3d< double > &p) const
Definition: cd_vector.h:348
ConvexDecomposition::Vector2d::FasterNormalize
Type FasterNormalize(void)
Definition: cd_vector.h:1157
ConvexDecomposition::Vector3d::negative
Vector3d negative(void) const
Definition: cd_vector.h:296
ConvexDecomposition::Vector3d::Vector3d
Vector3d(const int *t)
Definition: cd_vector.h:108
ConvexDecomposition::Vector3d::FastLength
Type FastLength(void) const
Definition: cd_vector.h:437
ConvexDecomposition::Vector3d::Set
void Set(Type a, Type b, Type c)
Definition: cd_vector.h:279
ConvexDecomposition::Vector3d::Get
void Get(Type *v) const
Definition: cd_vector.h:257
ConvexDecomposition::Vector2d::fastmagnitude
Type fastmagnitude(void) const
Definition: cd_vector.h:1049
ConvexDecomposition::Vector2d::operator==
bool operator==(const Vector2d< Type > &a) const
Definition: cd_vector.h:957
ConvexDecomposition::Vector2d::Length2
Type Length2(void)
Definition: cd_vector.h:1076
ConvexDecomposition::Vector3d::NearestPointInPlane
void NearestPointInPlane(const Vector3d< Type > &point, const Vector3d< Type > &planePoint, const Vector3d< Type > &planeNormal)
Definition: cd_vector.h:790
ConvexDecomposition::Vector3d::Zero
void Zero(void)
Definition: cd_vector.h:286
ConvexDecomposition::Vector3d::operator-=
void operator-=(const Vector3d A)
Definition: cd_vector.h:162
ConvexDecomposition::Line::Line
Line(const Vector3d< double > &from, const Vector3d< double > &to)
Definition: cd_vector.h:1181
ConvexDecomposition::Vector3d::DistanceXY
Type DistanceXY(const Vector3d< Type > &a) const
Definition: cd_vector.h:473
ConvexDecomposition::Vector3d::FastMagnitude
Type FastMagnitude(void) const
Definition: cd_vector.h:310
ConvexDecomposition::Vector2d::FastNormalize
Type FastNormalize(void)
Definition: cd_vector.h:1141
ConvexDecomposition::Vector3d::Normalize
double Normalize(void)
Definition: cd_vector.h:502
ConvexDecomposition::Vector3d::ComputeNormal
double ComputeNormal(const Vector3d< double > &A, const Vector3d< double > &B, const Vector3d< double > &C)
Definition: cd_vector.h:206
ConvexDecomposition::Vector3d::operator=
Vector3d & operator=(const Vector3d &A)
Definition: cd_vector.h:126
ConvexDecomposition::Vector2d::operator*=
Vector2d & operator*=(const Vector2d &a)
Definition: cd_vector.h:943
ConvexDecomposition::Vector2d::Vector2d
Vector2d(const Vector2d &a)
Definition: cd_vector.h:907
ConvexDecomposition::Vector3d::Z
Type Z(void) const
Definition: cd_vector.h:188
ConvexDecomposition::Line
Definition: cd_vector.h:1178
ConvexDecomposition::Vector3d::SetZ
void SetZ(Type t)
Definition: cd_vector.h:192
ConvexDecomposition::Vector3d::z
Type z
Definition: cd_vector.h:898
ConvexDecomposition::Line::mP2
Vector3d< double > mP2
Definition: cd_vector.h:1191
ConvexDecomposition::Vector2d::fastermagnitude
Type fastermagnitude(void) const
Definition: cd_vector.h:1054
ConvexDecomposition::Vector3d::operator[]
Type operator[](const int i) const
Definition: cd_vector.h:175
ConvexDecomposition::Vector3d::operator!=
bool operator!=(const Vector3d< Type > &a) const
Definition: cd_vector.h:120
ConvexDecomposition::Vector2dVector
std::vector< Vector2d< double > > Vector2dVector
Definition: cd_vector.h:1197
ConvexDecomposition::Vector2d::FastLength
Type FastLength(void) const
Definition: cd_vector.h:1066
ConvexDecomposition::Vector3d::Cross
void Cross(const Vector3d< Type > &a, const Vector3d< Type > &b)
Definition: cd_vector.h:569
ConvexDecomposition::Vector2d::Lerp
void Lerp(const Vector2d< Type > &from, const Vector2d< Type > &to, double slerp)
Definition: cd_vector.h:1112
ConvexDecomposition::dot
double dot(const double3 &a, const double3 &b)
Definition: cd_hull.cpp:661
ConvexDecomposition::Vector2d::operator+
Vector2d operator+(Vector2d a) const
Definition: cd_vector.h:969
ConvexDecomposition::Vector2d::Zero
void Zero(void)
Definition: cd_vector.h:1030
ConvexDecomposition::Vector3d::SetX
void SetX(Type t)
Definition: cd_vector.h:190
ConvexDecomposition::Vector3d::Lerp
void Lerp(const Vector3d< Type > &from, const Vector3d< Type > &to, double slerp)
Definition: cd_vector.h:320
ConvexDecomposition::Vector3d::operator/=
void operator/=(Type A)
Definition: cd_vector.h:157
ConvexDecomposition::Vector3d::PointTestXY
bool PointTestXY(const Vector3d< double > &i, const Vector3d< double > &j) const
Definition: cd_vector.h:632
ConvexDecomposition::Vector3d::Cross
Vector3d< Type > Cross(const Vector3d< Type > &other) const
Definition: cd_vector.h:562
ConvexDecomposition::Vector3d::operator+
Vector3d operator+(const Vector3d &A) const
Definition: cd_vector.h:130
ConvexDecomposition::Vector3d::Concave
bool Concave(const Vector3d< double > &a, const Vector3d< double > &b)
Definition: cd_vector.h:582
ConvexDecomposition::Vector3d::FastNormalize
double FastNormalize(void)
Definition: cd_vector.h:519
ConvexDecomposition::Vector3d::GetZ
Type GetZ(void) const
Definition: cd_vector.h:184
ConvexDecomposition::Vector3d::Magnitude
Type Magnitude(void) const
Definition: cd_vector.h:305
ConvexDecomposition::Vector3d::PointInTriXY
bool PointInTriXY(const Vector3d< double > &p1, const Vector3d< double > &p2, const Vector3d< double > &p3) const
Definition: cd_vector.h:642
ConvexDecomposition::Vector3d::NearestPointInTriangle
void NearestPointInTriangle(const Vector3d< Type > &point, const Vector3d< Type > &triangle0, const Vector3d< Type > &triangle1, const Vector3d< Type > &triangle2)
Definition: cd_vector.h:803
ConvexDecomposition::Vector2d::FasterLength
Type FasterLength(void) const
Definition: cd_vector.h:1071
ConvexDecomposition::Vector3d::operator==
bool operator==(const Vector3d< Type > &a) const
Definition: cd_vector.h:115
ConvexDecomposition::Vector3d::Dot
Type Dot(const Vector3d< Type > &a) const
Definition: cd_vector.h:556
ConvexDecomposition
Definition: bestfit.cpp:75
ConvexDecomposition::Vector2d::operator/=
Vector2d & operator/=(const Vector2d &a)
Definition: cd_vector.h:950
ConvexDecomposition::Vector3d::IsSame
bool IsSame(const Vector3d< double > &v, double epsilon) const
Definition: cd_vector.h:194
ConvexDecomposition::Vector2d
Definition: cd_vector.h:902
ConvexDecomposition::Vector2d::negative
Vector2d negative(void) const
Definition: cd_vector.h:1036
ConvexDecomposition::Vector3d::ComputePlane
double ComputePlane(const Vector3d< double > &A, const Vector3d< double > &B, const Vector3d< double > &C)
Definition: cd_vector.h:397
ConvexDecomposition::Vector3d::AngleAxis
void AngleAxis(Type angle, const Vector3d< Type > &axis)
Definition: cd_vector.h:384
ConvexDecomposition::Vector2d::GetX
Type GetX(void) const
Definition: cd_vector.h:1018
ConvexDecomposition::Vector3d::PointInTriYZ
bool PointInTriYZ(const Vector3d< double > &p1, const Vector3d< double > &p2, const Vector3d< double > &p3) const
Definition: cd_vector.h:668
ConvexDecomposition::Vector2d::Normalize
Type Normalize(void)
Definition: cd_vector.h:1125
ConvexDecomposition::Vector3d::x
Type x
Definition: cd_vector.h:896
ConvexDecomposition::Vector3d::NearestPointInLine
void NearestPointInLine(const Vector3d< Type > &point, const Vector3d< Type > &line0, const Vector3d< Type > &line1)
Definition: cd_vector.h:721
ConvexDecomposition::Vector2d::Vector2d
Vector2d(const double *t)
Definition: cd_vector.h:913
ConvexDecomposition::Vector3d::FasterMagnitude
Type FasterMagnitude(void) const
Definition: cd_vector.h:315
ConvexDecomposition::Vector2d::operator*
Vector2d operator*(Vector2d a) const
Definition: cd_vector.h:988
ConvexDecomposition::Vector2d::Vector2d
Vector2d(void)
Definition: cd_vector.h:905
ConvexDecomposition::Vector2d::Vector2d
Vector2d(Type a, Type b)
Definition: cd_vector.h:920
ConvexDecomposition::Vector3d::Vector3d
Vector3d(const double *t)
Definition: cd_vector.h:101
ConvexDecomposition::Vector2d::SetY
void SetY(Type t)
Definition: cd_vector.h:1022
ConvexDecomposition::Vector2d::SetX
void SetX(Type t)
Definition: cd_vector.h:1021
ConvexDecomposition::Vector2d::operator!=
bool operator!=(const Vector2d &a) const
Definition: cd_vector.h:963
ConvexDecomposition::Vector3d::BinaryEqual
bool BinaryEqual(const Vector3d< int > &p) const
Definition: cd_vector.h:360
ConvexDecomposition::DEG_TO_RAD
const double DEG_TO_RAD
Definition: cd_vector.h:79
ConvexDecomposition::Vector3d::PointInTriXZ
bool PointInTriXZ(const Vector3d< double > &p1, const Vector3d< double > &p2, const Vector3d< double > &p3) const
Definition: cd_vector.h:695
ConvexDecomposition::Vector3d::GetX
Type GetX(void) const
Definition: cd_vector.h:182
ConvexDecomposition::Vector3d::X
Type X(void) const
Definition: cd_vector.h:186
ConvexDecomposition::Vector3d::FasterNormalize
double FasterNormalize(void)
Definition: cd_vector.h:536
ConvexDecomposition::slerp
Quaternion slerp(Quaternion a, const Quaternion &b, double interp)
Definition: cd_hull.cpp:1197
ConvexDecomposition::Vector3dVector
std::vector< Vector3d< double > > Vector3dVector
Definition: cd_vector.h:1196
ConvexDecomposition::Vector3d::Distance2
Type Distance2(const Vector3d< Type > &a) const
Definition: cd_vector.h:481
ConvexDecomposition::Vector3d::operator*
Vector3d operator*(const double s) const
Definition: cd_vector.h:138
ConvexDecomposition::Vector2d::operator+=
Vector2d & operator+=(const Vector2d &a)
Definition: cd_vector.h:929
ConvexDecomposition::Vector2d::x
Type x
Definition: cd_vector.h:1171
ConvexDecomposition::Vector2d::Distance
Type Distance(const Vector2d &a) const
Definition: cd_vector.h:1081
ConvexDecomposition::Vector3d::Area
Type Area(const Vector3d< Type > &p1, const Vector3d< Type > &p2) const
Definition: cd_vector.h:494
ConvexDecomposition::Vector2d::operator-=
Vector2d & operator-=(const Vector2d &a)
Definition: cd_vector.h:936
ConvexDecomposition::Vector3d::NearestPointInPlane
void NearestPointInPlane(const Vector3d< Type > &point, const Vector3d< Type > &triangle0, const Vector3d< Type > &triangle1, const Vector3d< Type > &triangle2)
Definition: cd_vector.h:770
ConvexDecomposition::Line::Intersect
bool Intersect(const Line &src, Vector3d< double > &sect)
ConvexDecomposition::Vector2d::operator/
Vector2d operator/(Vector2d a) const
Definition: cd_vector.h:1005
ConvexDecomposition::Vector3d::Vector3d
Vector3d(void)
Definition: cd_vector.h:85
ConvexDecomposition::Line::mP1
Vector3d< double > mP1
Definition: cd_vector.h:1190
ConvexDecomposition::Vector2d::Cross
void Cross(const Vector2d< Type > &a, const Vector2d< Type > &b)
Definition: cd_vector.h:1119
ConvexDecomposition::Vector3d::FasterDistance
Type FasterDistance(const Vector3d< Type > &a) const
Definition: cd_vector.h:466
ConvexDecomposition::Vector3d::Ptr
const Type * Ptr() const
Definition: cd_vector.h:291
ConvexDecomposition::Vector2d::Length
Type Length(void) const
Definition: cd_vector.h:1061
ConvexDecomposition::Vector2d::FasterDistance
Type FasterDistance(const Vector2d &a) const
Definition: cd_vector.h:1097
ConvexDecomposition::RAD_TO_DEG
const double RAD_TO_DEG
Definition: cd_vector.h:80
ConvexDecomposition::Vector3d::Ptr
Type * Ptr()
Definition: cd_vector.h:292
ConvexDecomposition::Vector3d::Reflection
void Reflection(const Vector3d< Type > &a, const Vector3d< Type > &b)
Definition: cd_vector.h:368
ConvexDecomposition::Vector3d::operator+=
void operator+=(const Vector3d A)
Definition: cd_vector.h:160
ConvexDecomposition::Vector2d::operator-
Vector2d operator-(void) const
Definition: cd_vector.h:983
ConvexDecomposition::Vector2d::operator-
Vector2d operator-(Vector2d a) const
Definition: cd_vector.h:976
ConvexDecomposition::Vector3d::FasterLength
Type FasterLength(void) const
Definition: cd_vector.h:443
ConvexDecomposition::Vector3d::Set
void Set(const int *p)
Definition: cd_vector.h:264
ConvexDecomposition::Vector2d::Dot
Type Dot(const Vector2d< Type > &a) const
Definition: cd_vector.h:1013
ConvexDecomposition::Vector2d::FastDistance
Type FastDistance(const Vector2d &a) const
Definition: cd_vector.h:1089
ConvexDecomposition::Vector3d::Interpolate
void Interpolate(const Vector3d< double > &from, const Vector3d< double > &to, double offset)
Definition: cd_vector.h:332
ConvexDecomposition::Vector2d::y
Type y
Definition: cd_vector.h:1175
ConvexDecomposition::Vector3d::Length2
Type Length2(void) const
Definition: cd_vector.h:448
ConvexDecomposition::Vector3d::Length
Type Length(void) const
Definition: cd_vector.h:391
ConvexDecomposition::Vector2d::GetY
Type GetY(void) const
Definition: cd_vector.h:1019
ConvexDecomposition::Vector3d::NearestPointInLineSegment
void NearestPointInLineSegment(const Vector3d< Type > &point, const Vector3d< Type > &line0, const Vector3d< Type > &line1)
Definition: cd_vector.h:742
ConvexDecomposition::point
Definition: planetri.cpp:128
ConvexDecomposition::Vector3d::GetY
Type GetY(void) const
Definition: cd_vector.h:183
ConvexDecomposition::Vector2d::operator*
Vector2d operator*(Type c) const
Definition: cd_vector.h:995
ConvexDecomposition::Vector3d::operator-
Vector3d operator-(void) const
Definition: cd_vector.h:171
ConvexDecomposition::Vector3d::FastDistance
Type FastDistance(const Vector3d< Type > &a) const
Definition: cd_vector.h:460
ConvexDecomposition::Vector3d::SetY
void SetY(Type t)
Definition: cd_vector.h:191
ConvexDecomposition::Vector3d::operator*=
void operator*=(const double s)
Definition: cd_vector.h:164
ConvexDecomposition::Vector3d::operator/
Vector3d operator/(const double s) const
Definition: cd_vector.h:150
ConvexDecomposition::operator*
double3 operator*(const double3 &v, const double s)
Definition: cd_hull.cpp:644
ConvexDecomposition::Vector2d::Set
void Set(Type a, Type b)
Definition: cd_vector.h:1024
ConvexDecomposition::Vector2d::magnitude
Type magnitude(void) const
Definition: cd_vector.h:1044
ConvexDecomposition::Vector2d::Reflection
void Reflection(Vector2d &a, Vector2d &b)
ConvexDecomposition::Vector3d::Set
void Set(const double *p)
Definition: cd_vector.h:271
ConvexDecomposition::Vector3d::SwapYZ
void SwapYZ(void)
Definition: cd_vector.h:250


convex_decomposition
Author(s): John W. Ratcliff
autogenerated on Wed Mar 2 2022 00:04:59