Point Cloud Library (PCL)  1.9.1-dev
opennurbs_point.h
1 /* $NoKeywords: $ */
2 /*
3 //
4 // Copyright (c) 1993-2012 Robert McNeel & Associates. All rights reserved.
5 // OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert
6 // McNeel & Associates.
7 //
8 // THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
9 // ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
10 // MERCHANTABILITY ARE HEREBY DISCLAIMED.
11 //
12 // For complete openNURBS copyright information see <http://www.opennurbs.org>.
13 //
14 ////////////////////////////////////////////////////////////////
15 */
16 
17 ////////////////////////////////////////////////////////////////
18 //
19 // defines double precision point, vector, and array classes
20 //
21 ////////////////////////////////////////////////////////////////
22 #if !defined(ON_POINT_INC_)
23 #define ON_POINT_INC_
24 
25 #include <pcl/pcl_exports.h>
26 
27 class ON_BoundingBox;
28 class ON_Xform;
29 class ON_Line;
30 class ON_Plane;
31 
32 class ON_2dPoint;
33 class ON_3dPoint;
34 class ON_4dPoint;
35 
36 class ON_2dVector;
37 class ON_3dVector;
38 
39 class ON_2fVector;
40 class ON_3fVector;
41 
42 class ON_Interval;
43 
44 ////////////////////////////////////////////////////////////////
45 //
46 // ON_Interval
47 //
48 class PCL_EXPORTS ON_CLASS ON_Interval
49 {
50 public:
51 
52  static const ON_Interval EmptyInterval; // (ON_UNSET_VALUE,ON_UNSET_VALUE)
53 
54  ////////
55  // The default constructor creates an empty interval (ON_UNSET_VALUE,ON_UNSET_VALUE)
56  ON_Interval();
57 
58  ON_Interval(double t0,double t1);
59 
60  ~ON_Interval();
61 
62  bool operator!=(const ON_Interval&) const;
63  bool operator==(const ON_Interval&) const;
64 
65  // Interval = [m_t[0], m_t[1]]
66  double m_t[2];
67 
68  /*
69  Description:
70  Sets interval to (ON_UNSET_VALUE,ON_UNSET_VALUE)
71  See Also:
72  ON_Interval::Set
73  */
74  void Destroy();
75 
76  /*
77  Description:
78  Sets interval to [t0,t1]
79  Parameters:
80  t0 - [in]
81  t1 - [in]
82  See Also:
83  ON_Interval::ON_Interval( double, double )
84  */
85  void Set(
86  double t0,
87  double t1
88  );
89 
90  /*
91  Description:
92  Convert normalized parameter to interval value, or pair of values.
93  Parameters:
94  normalized_parameter - [in]
95  Returns:
96  Interval parameter
97  min*(1.0-normalized_parameter) + max*normalized_parameter
98  See Also:
99  ON_Interval::NormalizedParameterAt
100  */
101  double ParameterAt (
102  double normalized_parameter
103  ) const;
104  ON_Interval ParameterAt (
105  ON_Interval normalized_interval
106  ) const;
107 
108  /*
109  Description:
110  Convert interval value, or pair of values, to normalized parameter.
111  Parameters:
112  interval_parameter - [in] value in interval
113  Returns:
114  Normalized parameter x so that
115  min*(1.0-x) + max*x = interval_parameter.
116  See Also:
117  ON_Interval::ParameterAt
118  */
119  double NormalizedParameterAt (
120  double interval_parameter
121  ) const;
122  ON_Interval NormalizedParameterAt (
123  ON_Interval interval_parameter
124  ) const;
125 
126  double& operator[](int); // returns (index<=0) ? m_t[0] : m_t[1]
127  double operator[](int) const; // returns (index<=0) ? m_t[0] : m_t[1]
128  double& operator[](unsigned int); // returns (index<=0) ? m_t[0] : m_t[1]
129  double operator[](unsigned int) const; // returns (index<=0) ? m_t[0] : m_t[1]
130 
131  double Min() const; // returns smaller of m_t[0] and m_t[1]
132  double Max() const; // returns larger of m_t[0] and m_t[1]
133  double Mid() const; // returns 0.5*(m_t[0] + m_t[1])
134  double Length() const;
135 
136  bool IsIncreasing() const; // returns true if m_t[0] < m_t[1]
137  bool IsDecreasing() const; // returns true if m_t[0] > m_t[0];
138  bool IsInterval() const; // returns truc if m_t[0] != m_t[1]
139  bool IsSingleton() const; // returns true if m_t[0] == m_t[1] != ON_UNSET_VALUE
140  bool IsEmptyInterval() const; // returns true if m_t[0] == m_t[1] == ON_UNSET_VALUE
141  bool IsValid() const; // returns ON_IsValid(m_t[0]) && ON_IsValid(m_t[1])
142 
143  // OBSOLETE - Use IsEmptyInterval()
144  bool IsEmptySet() const; // returns true if m_t[0] == m_t[1] == ON_UNSET_VALUE
145 
146  bool MakeIncreasing(); // returns true if resulting interval IsIncreasing()
147 
148  /*
149  Returns:
150  @untitled table
151  0 this is idential to other
152  -1 this[0] < other[0]
153  +1 this[0] > other[0]
154  -1 this[0] == other[0] and this[1] < other[1]
155  +1 this[0] == other[0] and this[1] > other[1]
156  */
157  int Compare( const ON_Interval& other ) const;
158 
159  /*
160  Description:
161  Test a value t to see if it is inside the interval.
162  Parameters:
163  t - [in] value to test
164  bTestOpenInterval - [in]
165  If false, t is tested to see if it satisfies min <= t <= max.
166  If true, t is tested to see if it satisfies min < t < max.
167  Returns:
168  true if t is in the interval and false if t is not
169  in the interval.
170  */
171  bool Includes(
172  double t,
173  bool bTestOpenInterval = false
174  ) const;
175 
176  /*
177  Description:
178  Test an interval to see if it is contained in this interval.
179  Parameters:
180  other - [in] interval to test
181  bProperSubSet - [in] if true, then the test is for a proper subinterval.
182  Returns:
183  If bProperSubSet is false, then the result is true when
184  this->Min() <= other.Min() and other.Max() <= this->Max().
185  If bProperSubSet is true, then the result is true when
186  this->Min() <= other.Min() and other.Max() <= this->Max()
187  and at least one of the inequalites is strict.
188  */
189  bool Includes(
190  const ON_Interval& other,
191  bool bProperSubSet = false
192  ) const;
193 
194  /*
195  Description:
196  Changes interval to [-m_t[1],-m_t[0]].
197  */
198  void Reverse();
199 
200  /*
201  Description:
202  Swaps m_t[0] and m_t[1].
203  */
204  void Swap();
205 
206  //////////
207  // If the intersection is not empty, then
208  // intersection = [max(this.Min(),arg.Min()), min(this.Max(),arg.Max())]
209  // Intersection() returns true if the intersection is not empty.
210  // The interval [ON_UNSET_VALUE,ON_UNSET_VALUE] is considered to be
211  // the empty set interval. The result of any intersection involving an
212  // empty set interval or disjoint intervals is the empty set interval.
213  bool Intersection( // this = this intersect arg
214  const ON_Interval&
215  );
216 
217  //////////
218  // If the intersection is not empty, then
219  // intersection = [max(argA.Min(),argB.Min()), min(argA.Max(),argB.Max())]
220  // Intersection() returns true if the intersection is not empty.
221  // The interval [ON_UNSET_VALUE,ON_UNSET_VALUE] is considered to be
222  // the empty set interval. The result of any intersection involving an
223  // empty set interval or disjoint intervals is the empty set interval.
224  bool Intersection( // this = intersection of two args
225  const ON_Interval&,
226  const ON_Interval&
227  );
228 
229  //////////
230  // The union of an empty set and an increasing interval is the increasing
231  // interval. The union of two empty sets is empty. The union of an empty
232  // set an a non-empty interval is the non-empty interval.
233  // The union of two non-empty intervals is
234  // union = [min(this.Min(),arg.Min()), max(this.Max(),arg.Max()),]
235  // Union() returns true if the union is not empty.
236  bool Union( // this = this union arg
237  const ON_Interval&
238  );
239 
240  bool Union( // this = this union arg
241  double t
242  );
243 
244  bool Union( // this = this union arg
245  int count,
246  const double* t
247  );
248 
249  //////////
250  // The union of an empty set and an increasing interval is the increasing
251  // interval. The union of two empty sets is empty. The union of an empty
252  // set an a non-empty interval is the non-empty interval.
253  // The union of two non-empty intervals is
254  // union = [min(argA.Min(),argB.Min()), max(argA.Max(),argB.Max()),]
255  // Union() returns true if the union is not empty.
256  bool Union( // this = union of two args
257  const ON_Interval&,
258  const ON_Interval&
259  );
260 };
261 
262 ////////////////////////////////////////////////////////////////
263 //
264 // ON_2dPoint
265 //
266 class PCL_EXPORTS ON_CLASS ON_2dPoint
267 {
268 public:
269  double x, y;
270 
271  static const ON_2dPoint Origin; // (0.0,0.0)
272  static const ON_2dPoint UnsetPoint; // (ON_UNSET_VALUE,ON_UNSET_VALUE)
273 
274  // use implicit destructor, copy constructor
275  ON_2dPoint(); // x,y not initialized
276  ON_2dPoint(double x,double y);
277  ON_2dPoint(const ON_3dPoint& ); // from 3d point
278  ON_2dPoint(const ON_4dPoint& ); // from 4d point
279  ON_2dPoint(const ON_2dVector& ); // from 2d vector
280  ON_2dPoint(const ON_3dVector& ); // from 3d vector
281  ON_2dPoint(const double*); // from double[2] array
282 
283  ON_2dPoint(const class ON_2fPoint&); // from 2f point
284  ON_2dPoint(const class ON_3fPoint&); // from 3f point
285  ON_2dPoint(const class ON_4fPoint&); // from 4f point
286  ON_2dPoint(const class ON_2fVector&); // from 2f point
287  ON_2dPoint(const class ON_3fVector&); // from 3f point
288  ON_2dPoint(const float*); // from float[2] array
289 
290  // (double*) conversion operators
291  operator double*();
292  operator const double*() const;
293 
294  // use implicit operator=(const ON_2dPoint&)
295  ON_2dPoint& operator=(const ON_3dPoint&);
296  ON_2dPoint& operator=(const ON_4dPoint&);
297  ON_2dPoint& operator=(const ON_2dVector&);
298  ON_2dPoint& operator=(const ON_3dVector&);
299  ON_2dPoint& operator=(const double*); // point = double[2] support
300 
301  ON_2dPoint& operator=(const ON_2fPoint&);
302  ON_2dPoint& operator=(const ON_3fPoint&);
303  ON_2dPoint& operator=(const ON_4fPoint&);
304  ON_2dPoint& operator=(const ON_2fVector&);
305  ON_2dPoint& operator=(const ON_3fVector&);
306  ON_2dPoint& operator=(const float*); // point = float[2] support
307 
308  ON_2dPoint& operator*=(double);
309  ON_2dPoint& operator/=(double);
310  ON_2dPoint& operator+=(const ON_2dPoint&); // Adding this was a mistake - cannot remove without breaking SDK
311  ON_2dPoint& operator+=(const ON_2dVector&);
312  ON_2dPoint& operator+=(const ON_3dVector&); // Adding this was a mistake - cannot remove without breaking SDK
313  ON_2dPoint& operator-=(const ON_2dPoint&); // Adding this was a mistake - cannot remove without breaking SDK
314  ON_2dPoint& operator-=(const ON_2dVector&);
315  ON_2dPoint& operator-=(const ON_3dVector&); // Adding this was a mistake - cannot remove without breaking SDK
316 
317  ON_2dPoint operator*(int) const;
318  ON_2dPoint operator/(int) const;
319  ON_2dPoint operator*(float) const;
320  ON_2dPoint operator/(float) const;
321  ON_2dPoint operator*(double) const;
322  ON_2dPoint operator/(double) const;
323 
324  ON_2dPoint operator+(const ON_2dPoint&) const;
325  ON_2dPoint operator+(const ON_2dVector&) const;
326  ON_2dVector operator-(const ON_2dPoint&) const;
327  ON_2dPoint operator-(const ON_2dVector&) const;
328  ON_3dPoint operator+(const ON_3dPoint&) const;
329  ON_3dPoint operator+(const ON_3dVector&) const;
330  ON_3dVector operator-(const ON_3dPoint&) const;
331  ON_3dPoint operator-(const ON_3dVector&) const;
332 
333  ON_2dPoint operator+(const ON_2fPoint&) const;
334  ON_2dPoint operator+(const ON_2fVector&) const;
335  ON_2dVector operator-(const ON_2fPoint&) const;
336  ON_2dPoint operator-(const ON_2fVector&) const;
337  ON_3dPoint operator+(const ON_3fPoint&) const;
338  ON_3dPoint operator+(const ON_3fVector&) const;
339  ON_3dVector operator-(const ON_3fPoint&) const;
340  ON_3dPoint operator-(const ON_3fVector&) const;
341 
342  double operator*(const ON_2dPoint&) const; // dot product for points acting as vectors
343  double operator*(const ON_2dVector&) const; // dot product for points acting as vectors
344  double operator*(const ON_4dPoint&) const;
345  ON_2dPoint operator*(const ON_Xform&) const;
346 
347  bool operator==(const ON_2dPoint&) const;
348  bool operator!=(const ON_2dPoint&) const;
349 
350  // dictionary order comparisons
351  bool operator<=(const ON_2dPoint&) const;
352  bool operator>=(const ON_2dPoint&) const;
353  bool operator<(const ON_2dPoint&) const;
354  bool operator>(const ON_2dPoint&) const;
355 
356  // index operators mimic double[2] behavior
357  double& operator[](int);
358  double operator[](int) const;
359  double& operator[](unsigned int);
360  double operator[](unsigned int) const;
361 
362  /*
363  Returns:
364  False if any coordinate is infinte, a nan, or ON_UNSET_VALUE.
365  */
366  bool IsValid() const;
367 
368  /*
369  Returns:
370  True if every coordinate is ON_UNSET_VALUE.
371  */
372  bool IsUnsetPoint() const;
373 
374  // set 2d point value
375  void Set(double x,double y);
376 
377  double DistanceTo( const ON_2dPoint& ) const;
378 
379  int MaximumCoordinateIndex() const;
380  double MaximumCoordinate() const; // absolute value of maximum coordinate
381 
382  int MinimumCoordinateIndex() const;
383  double MinimumCoordinate() const; // absolute value of minimum coordinate
384 
385  void Zero(); // set all coordinates to zero;
386 
387  // These transform the point in place. The transformation matrix acts on
388  // the left of the point; i.e., result = transformation*point
389  void Transform(
390  const ON_Xform&
391  );
392 
393  void Rotate( // rotatation in XY plane
394  double angle, // angle in radians
395  const ON_2dPoint& center // center of rotation
396  );
397 
398  void Rotate( // rotatation in XY plane
399  double sin_angle, // sin(angle)
400  double cos_angle, // cos(angle)
401  const ON_2dPoint& center // center of rotation
402  );
403 };
404 
405 ON_DECL
406 ON_2dPoint operator*(int, const ON_2dPoint&);
407 
408 ON_DECL
409 ON_2dPoint operator*(float, const ON_2dPoint&);
410 
411 ON_DECL
412 ON_2dPoint operator*(double, const ON_2dPoint&);
413 
414 ////////////////////////////////////////////////////////////////
415 //
416 // ON_3dPoint
417 //
418 class PCL_EXPORTS ON_CLASS ON_3dPoint
419 {
420 public:
421  double x, y, z;
422 
423  static const ON_3dPoint Origin; // (0.0,0.0,0.0)
424  static const ON_3dPoint UnsetPoint; // (ON_UNSET_VALUE,ON_UNSET_VALUE,ON_UNSET_VALUE)
425 
426  // use implicit destructor, copy constructor
427  ON_3dPoint(); // x,y,z not initialized
428  ON_3dPoint(double x,double y,double z);
429  ON_3dPoint(const ON_2dPoint& ); // from 2d point
430  ON_3dPoint(const ON_4dPoint& ); // from 4d point
431  ON_3dPoint(const ON_2dVector& ); // from 2d vector
432  ON_3dPoint(const ON_3dVector& ); // from 3d vector
433  ON_3dPoint(const double*); // from double[3] array
434 
435  ON_3dPoint(const class ON_2fPoint&); // from 2f point
436  ON_3dPoint(const class ON_3fPoint&); // from 3f point
437  ON_3dPoint(const class ON_4fPoint&); // from 4f point
438  ON_3dPoint(const class ON_2fVector&); // from 2f point
439  ON_3dPoint(const class ON_3fVector&); // from 3f point
440  ON_3dPoint(const float*); // from float[3] array
441 
442  // (double*) conversion operators
443  operator double*();
444  operator const double*() const;
445 
446  // use implicit operator=(const ON_3dPoint&)
447  ON_3dPoint& operator=(const ON_2dPoint&);
448  ON_3dPoint& operator=(const ON_4dPoint&);
449  ON_3dPoint& operator=(const ON_2dVector&);
450  ON_3dPoint& operator=(const ON_3dVector&);
451  ON_3dPoint& operator=(const double*); // point = double[3] support
452 
453  ON_3dPoint& operator=(const class ON_2fPoint&);
454  ON_3dPoint& operator=(const class ON_3fPoint&);
455  ON_3dPoint& operator=(const class ON_4fPoint&);
456  ON_3dPoint& operator=(const class ON_2fVector&);
457  ON_3dPoint& operator=(const class ON_3fVector&);
458  ON_3dPoint& operator=(const float*); // point = float[3] support
459 
460  ON_3dPoint& operator*=(double);
461  ON_3dPoint& operator/=(double);
462  ON_3dPoint& operator+=(const ON_3dPoint&); // Adding this was a mistake - cannot remove without breaking SDK
463  ON_3dPoint& operator+=(const ON_3dVector&);
464  ON_3dPoint& operator-=(const ON_3dPoint&); // Adding this was a mistake - cannot remove without breaking SDK
465  ON_3dPoint& operator-=(const ON_3dVector&);
466 
467  ON_3dPoint operator*(int) const;
468  ON_3dPoint operator/(int) const;
469  ON_3dPoint operator*(float) const;
470  ON_3dPoint operator/(float) const;
471  ON_3dPoint operator*(double) const;
472  ON_3dPoint operator/(double) const;
473 
474  ON_3dPoint operator+(const ON_3dPoint&) const;
475  ON_3dPoint operator+(const ON_3dVector&) const;
476  ON_3dVector operator-(const ON_3dPoint&) const;
477  ON_3dPoint operator-(const ON_3dVector&) const;
478  ON_3dPoint operator+(const ON_2dPoint&) const;
479  ON_3dPoint operator+(const ON_2dVector&) const;
480  ON_3dVector operator-(const ON_2dPoint&) const;
481  ON_3dPoint operator-(const ON_2dVector&) const;
482 
483  ON_3dPoint operator+(const ON_3fPoint&) const;
484  ON_3dPoint operator+(const ON_3fVector&) const;
485  ON_3dVector operator-(const ON_3fPoint&) const;
486  ON_3dPoint operator-(const ON_3fVector&) const;
487  ON_3dPoint operator+(const ON_2fPoint&) const;
488  ON_3dPoint operator+(const ON_2fVector&) const;
489  ON_3dVector operator-(const ON_2fPoint&) const;
490  ON_3dPoint operator-(const ON_2fVector&) const;
491 
492  double operator*(const ON_3dPoint&) const; // dot product for points acting as vectors
493  double operator*(const ON_3dVector&) const; // dot product for points acting as vectors
494  double operator*(const ON_4dPoint&) const;
495  ON_3dPoint operator*(const ON_Xform&) const;
496 
497  bool operator==(const ON_3dPoint&) const;
498  bool operator!=(const ON_3dPoint&) const;
499 
500  // dictionary order comparisons
501  bool operator<=(const ON_3dPoint&) const;
502  bool operator>=(const ON_3dPoint&) const;
503  bool operator<(const ON_3dPoint&) const;
504  bool operator>(const ON_3dPoint&) const;
505 
506  // index operators mimic double[3] behavior
507  double& operator[](int);
508  double operator[](int) const;
509  double& operator[](unsigned int);
510  double operator[](unsigned int) const;
511 
512  /*
513  Returns:
514  False if any coordinate is infinte, a nan, or ON_UNSET_VALUE.
515  */
516  bool IsValid() const;
517 
518  /*
519  Returns:
520  True if every coordinate is ON_UNSET_VALUE.
521  */
522  bool IsUnsetPoint() const;
523 
524  // set 3d point value
525  void Set(double x,double y,double z);
526 
527  double DistanceTo( const ON_3dPoint& ) const;
528 
529  int MaximumCoordinateIndex() const;
530  double MaximumCoordinate() const; // absolute value of maximum coordinate
531 
532  int MinimumCoordinateIndex() const;
533  double MinimumCoordinate() const; // absolute value of minimum coordinate
534 
535  double Fuzz( double tolerance = ON_ZERO_TOLERANCE ) const; // tolerance to use when comparing 3d points
536 
537  void Zero(); // set all coordinates to zero;
538 
539  // These transform the point in place. The transformation matrix acts on
540  // the left of the point; i.e., result = transformation*point
541  void Transform(
542  const ON_Xform&
543  );
544 
545  void Rotate(
546  double angle, // angle in radians
547  const ON_3dVector& axis, // axis of rotation
548  const ON_3dPoint& center // center of rotation
549  );
550 
551  void Rotate(
552  double sin_angle, // sin(angle)
553  double cos_angle, // cos(angle)
554  const ON_3dVector& axis, // axis of rotation
555  const ON_3dPoint& center // center of rotation
556  );
557 };
558 
559 ON_DECL
560 ON_3dPoint operator*(int, const ON_3dPoint&);
561 
562 ON_DECL
563 ON_3dPoint operator*(float, const ON_3dPoint&);
564 
565 ON_DECL
566 ON_3dPoint operator*(double, const ON_3dPoint&);
567 
568 ////////////////////////////////////////////////////////////////
569 //
570 // ON_4dPoint (homogeneous coordinates)
571 //
572 class PCL_EXPORTS ON_CLASS ON_4dPoint
573 {
574 public:
575  double x, y, z, w;
576 
577  // use implicit destructor, copy constructor
578  ON_4dPoint(); // x,y,z,w not initialized
579  ON_4dPoint(double x,double y,double z,double w);
580 
581  ON_4dPoint(const ON_2dPoint& ); // from 2d point
582  ON_4dPoint(const ON_3dPoint& ); // from 3d point
583  ON_4dPoint(const ON_2dVector& ); // from 2d vector
584  ON_4dPoint(const ON_3dVector& ); // from 3d vector
585  ON_4dPoint(const double*); // from double[4] array
586 
587  ON_4dPoint(const ON_2fPoint& ); // from 2f point
588  ON_4dPoint(const ON_3fPoint& ); // from 3f point
589  ON_4dPoint(const ON_4fPoint& ); // from 3f point
590  ON_4dPoint(const ON_2fVector& ); // from 2f vector
591  ON_4dPoint(const ON_3fVector& ); // from 3f vector
592  ON_4dPoint(const float*); // from float[4] array
593 
594  // (double*) conversion operators
595  operator double*();
596  operator const double*() const;
597 
598  // use implicit operator=(const ON_4dPoint&)
599  ON_4dPoint& operator=(const ON_2dPoint&);
600  ON_4dPoint& operator=(const ON_3dPoint&);
601  ON_4dPoint& operator=(const ON_2dVector&);
602  ON_4dPoint& operator=(const ON_3dVector&);
603  ON_4dPoint& operator=(const double*); // point = double[4] support
604 
605  ON_4dPoint& operator=(const class ON_2fPoint&);
606  ON_4dPoint& operator=(const class ON_3fPoint&);
607  ON_4dPoint& operator=(const class ON_4fPoint&);
608  ON_4dPoint& operator=(const class ON_2fVector&);
609  ON_4dPoint& operator=(const class ON_3fVector&);
610  ON_4dPoint& operator=(const float*); // point = float[4] support
611 
612  ON_4dPoint& operator*=(double);
613  ON_4dPoint& operator/=(double);
614  ON_4dPoint& operator+=(const ON_4dPoint&); // sum w = sqrt(|w1*w2|)
615  ON_4dPoint& operator-=(const ON_4dPoint&); // difference w = sqrt(|w1*w2|)
616 
617  ON_4dPoint operator*(double) const;
618  ON_4dPoint operator/(double) const;
619  ON_4dPoint operator+(const ON_4dPoint&) const; // sum w = sqrt(|w1*w2|)
620  ON_4dPoint operator-(const ON_4dPoint&) const; // difference w = sqrt(|w1*w2|)
621 
622  double operator*(const ON_4dPoint&) const;
623  ON_4dPoint operator*(const ON_Xform&) const;
624 
625  // projective comparison
626  // (i.e., [x,y,z,w] == [c*x,c*y,c*z,c*w] is true for nonzero c)
627  bool operator==(ON_4dPoint) const;
628  bool operator!=(const ON_4dPoint&) const;
629 
630  // index operators mimic double[4] behavior
631  double& operator[](int);
632  double operator[](int) const;
633  double& operator[](unsigned int);
634  double operator[](unsigned int) const;
635 
636  /*
637  Returns:
638  False if any coordinate is infinte, a nan, or ON_UNSET_VALUE.
639  */
640  bool IsValid() const;
641 
642  /*
643  Returns:
644  True if every coordinate is ON_UNSET_VALUE.
645  */
646  bool IsUnsetPoint() const;
647 
648  // set 4d point value
649  void Set(double x,double y,double z,double w);
650 
651  int MaximumCoordinateIndex() const;
652  double MaximumCoordinate() const; // absolute value of maximum coordinate
653 
654  int MinimumCoordinateIndex() const;
655  double MinimumCoordinate() const; // absolute value of minimum coordinate
656 
657  void Zero(); // set all 4 coordinates to zero;
658  bool Normalize(); // set so x^2 + y^2 + z^2 + w^2 = 1
659 
660  // These transform the point in place. The transformation matrix acts on
661  // the left of the point; i.e., result = transformation*point
662  void Transform(
663  const ON_Xform&
664  );
665 };
666 
667 ON_DECL
668 ON_4dPoint operator*(double, const ON_4dPoint&);
669 
670 ////////////////////////////////////////////////////////////////
671 //
672 // ON_2dVector
673 //
674 class PCL_EXPORTS ON_CLASS ON_2dVector
675 {
676 public:
677  double x, y;
678 
679  static const ON_2dVector ZeroVector; // (0.0,0.0)
680  static const ON_2dVector XAxis; // (1.0,0.0)
681  static const ON_2dVector YAxis; // (0.0,1.0)
682  static const ON_2dVector UnsetVector; // (ON_UNSET_VALUE,ON_UNSET_VALUE)
683 
684  // Description:
685  // A index driven function to get unit axis vectors.
686  // Parameters:
687  // index - [in] 0 returns (1,0), 1 returns (0,1)
688  // Returns:
689  // Unit 2d vector with vector[i] = (i==index)?1:0;
690  static const ON_2dVector& UnitVector(
691  int // index
692  );
693 
694  // use implicit destructor, copy constructor
695  ON_2dVector(); // x,y not initialized
696  ON_2dVector(double x,double y);
697 
698  ON_2dVector(const ON_3dVector& ); // from 3d vector
699  ON_2dVector(const ON_2dPoint& ); // from 2d point
700  ON_2dVector(const ON_3dPoint& ); // from 3d point
701  ON_2dVector(const double*); // from double[2] array
702 
703  ON_2dVector(const ON_2fVector& ); // from 2f vector
704  ON_2dVector(const ON_3fVector& ); // from 3f vector
705  ON_2dVector(const ON_2fPoint& ); // from 2f point
706  ON_2dVector(const ON_3fPoint& ); // from 3f point
707  ON_2dVector(const float*); // from double[2] array
708 
709  // (double*) conversion operators
710  operator double*();
711  operator const double*() const;
712 
713  // use implicit operator=(const ON_2dVector&)
714  ON_2dVector& operator=(const ON_3dVector&);
715  ON_2dVector& operator=(const ON_2dPoint&);
716  ON_2dVector& operator=(const ON_3dPoint&);
717  ON_2dVector& operator=(const double*); // vector = double[2] support
718 
719  ON_2dVector& operator=(const ON_2fVector&);
720  ON_2dVector& operator=(const ON_3fVector&);
721  ON_2dVector& operator=(const ON_2fPoint&);
722  ON_2dVector& operator=(const ON_3fPoint&);
723  ON_2dVector& operator=(const float*); // vector = float[2] support
724 
725  ON_2dVector operator-() const;
726 
727  ON_2dVector& operator*=(double);
728  ON_2dVector& operator/=(double);
729  ON_2dVector& operator+=(const ON_2dVector&);
730  ON_2dVector& operator-=(const ON_2dVector&);
731  // DO NOT ADD ANY MORE overrides of += or -=
732 
733  double operator*(const ON_2dVector&) const; // inner (dot) product
734  double operator*(const ON_2dPoint&) const; // inner (dot) product (point acting as vector)
735  double operator*(const ON_2fVector&) const; // inner (dot) product
736 
737  ON_2dVector operator*(int) const;
738  ON_2dVector operator/(int) const;
739  ON_2dVector operator*(float) const;
740  ON_2dVector operator/(float) const;
741  ON_2dVector operator*(double) const;
742  ON_2dVector operator/(double) const;
743 
744  ON_2dVector operator+(const ON_2dVector&) const;
745  ON_2dPoint operator+(const ON_2dPoint&) const;
746  ON_2dVector operator-(const ON_2dVector&) const;
747  ON_2dPoint operator-(const ON_2dPoint&) const;
748  ON_3dVector operator+(const ON_3dVector&) const;
749  ON_3dPoint operator+(const ON_3dPoint&) const;
750  ON_3dVector operator-(const ON_3dVector&) const;
751  ON_3dPoint operator-(const ON_3dPoint&) const;
752 
753  ON_2dVector operator+(const ON_2fVector&) const;
754  ON_2dPoint operator+(const ON_2fPoint&) const;
755  ON_2dVector operator-(const ON_2fVector&) const;
756  ON_2dPoint operator-(const ON_2fPoint&) const;
757  ON_3dVector operator+(const ON_3fVector&) const;
758  ON_3dPoint operator+(const ON_3fPoint&) const;
759  ON_3dVector operator-(const ON_3fVector&) const;
760  ON_3dPoint operator-(const ON_3fPoint&) const;
761 
762  double operator*(const ON_4dPoint&) const;
763  ON_2dVector operator*(const ON_Xform&) const;
764 
765  bool operator==(const ON_2dVector&) const;
766  bool operator!=(const ON_2dVector&) const;
767 
768  // dictionary order comparisons
769  bool operator<=(const ON_2dVector&) const;
770  bool operator>=(const ON_2dVector&) const;
771  bool operator<(const ON_2dVector&) const;
772  bool operator>(const ON_2dVector&) const;
773 
774  // index operators mimic double[2] behavior
775  double& operator[](int);
776  double operator[](int) const;
777  double& operator[](unsigned int);
778  double operator[](unsigned int) const;
779 
780  /*
781  Returns:
782  False if any coordinate is infinte, a nan, or ON_UNSET_VALUE.
783  */
784  bool IsValid() const;
785 
786  /*
787  Returns:
788  True if every coordinate is ON_UNSET_VALUE.
789  */
790  bool IsUnsetVector() const;
791 
792  // set 2d vector value
793  void Set(double x,double y);
794 
795  int MaximumCoordinateIndex() const;
796  double MaximumCoordinate() const; // absolute value of maximum coordinate
797 
798  int MinimumCoordinateIndex() const;
799  double MinimumCoordinate() const; // absolute value of minimum coordinate
800 
801  double LengthSquared() const;
802  double Length() const;
803 
804  // Signed area of the parallelagram. The volume element.
805  // returns x*B.y - y*B.x
806  double WedgeProduct(const ON_2dVector& B) const;
807 
808  bool Decompose( // Computes a, b such that this vector = a*X + b*Y
809  // Returns false if unable to solve for a,b. This happens
810  // when X,Y is not really a basis.
811  //
812  // If X,Y is known to be an orthonormal frame,
813  // then a = V*X, b = V*Y will compute
814  // the same result more quickly.
815  const ON_2dVector&, // X
816  const ON_2dVector&, // Y
817  double*, // a
818  double* // b
819  ) const;
820 
821  int IsParallelTo(
822  // returns 1: this and other vectors are parallel
823  // -1: this and other vectors are anti-parallel
824  // 0: this and other vectors are not parallel
825  // or at least one of the vectors is zero
826  const ON_2dVector& other, // other vector
827  double angle_tolerance = ON_DEFAULT_ANGLE_TOLERANCE // optional angle tolerance (radians)
828  ) const;
829 
830  bool IsPerpendicularTo(
831  // returns true: this and other vectors are perpendicular
832  // false: this and other vectors are not perpendicular
833  // or at least one of the vectors is zero
834  const ON_2dVector& other, // other vector
835  double angle_tolerance = ON_DEFAULT_ANGLE_TOLERANCE // optional angle tolerance (radians)
836  ) const;
837 
838  void Zero(); // set all coordinates to zero;
839  void Reverse(); // negate all coordinates
840  bool Unitize(); // returns false if vector has zero length
841 
842  // Description:
843  // Test a vector to see if it is very short
844  //
845  // Parameters:
846  // tiny_tol - [in] (default = ON_ZERO_TOLERANCE) a nonzero
847  // value used as the coordinate zero tolerance.
848  //
849  // Returns:
850  // ( fabs(x) <= tiny_tol && fabs(y) <= tiny_tol )
851  //
852  bool IsTiny(
853  double tiny_tol = ON_ZERO_TOLERANCE // tiny_tol
854  ) const;
855 
856  // Returns:
857  // true if vector is the zero vector.
858  bool IsZero() const;
859 
860  // Returns:
861  // true if vector is valid and has length 1.
862  bool IsUnitVector() const;
863 
864  // set this vector to be perpendicular to another vector
865  bool PerpendicularTo( // Result is not unitized.
866  // returns false if input vector is zero
867  const ON_2dVector&
868  );
869 
870  // set this vector to be perpendicular to a line defined by 2 points
871  bool PerpendicularTo(
872  const ON_2dPoint&,
873  const ON_2dPoint&
874  );
875 
876  // These transform the vector in place. The transformation matrix acts on
877  // the left of the vector; i.e., result = transformation*vector
878  void Transform(
879  const ON_Xform& // can use ON_Xform here
880  );
881 
882  void Rotate(
883  double angle // angle in radians
884  );
885 
886  void Rotate(
887  double sin_angle, // sin(angle)
888  double cos_angle // cos(angle)
889  );
890 };
891 
892 ON_DECL
893 ON_2dVector operator*(int, const ON_2dVector&);
894 
895 ON_DECL
896 ON_2dVector operator*(float, const ON_2dVector&);
897 
898 ON_DECL
899 ON_2dVector operator*(double, const ON_2dVector&);
900 
901 ///////////////////////////////////////////////////////////////
902 //
903 // ON_2dVector utilities
904 //
905 
906 ON_DECL
907 double
908 ON_DotProduct(
909  const ON_2dVector&,
910  const ON_2dVector&
911  );
912 
913 ON_DECL
915 ON_CrossProduct(
916  const ON_2dVector&,
917  const ON_2dVector&
918  );
919 
920 ON_DECL
921 double
922 ON_WedgeProduct( // signed area of the parallelagram. Volume element.
923  const ON_2dVector& A, // returns A.x * B.y - A.y * B.x
924  const ON_2dVector& B
925  );
926 
927 ON_DECL
928 bool
929 ON_IsOrthogonalFrame( // true if X, Y are nonzero and mutually perpendicular
930  const ON_2dVector&, // X
931  const ON_2dVector& // Y
932  );
933 
934 ON_DECL
935 bool
936 ON_IsOrthonormalFrame( // true if X, Y are orthogonal and unit length
937  const ON_2dVector&, // X
938  const ON_2dVector& // Y
939  );
940 
941 ON_DECL
942 bool
943 ON_IsRightHandFrame( // true if X, Y are orthonormal and right handed
944  const ON_2dVector&, // X
945  const ON_2dVector& // Y
946  );
947 
948 ////////////////////////////////////////////////////////////////
949 //
950 // ON_3dVector
951 //
952 class PCL_EXPORTS ON_CLASS ON_3dVector
953 {
954 public:
955  double x, y, z;
956 
957  static const ON_3dVector ZeroVector; // (0.0,0.0,0.0)
958  static const ON_3dVector XAxis; // (1.0,0.0,0.0)
959  static const ON_3dVector YAxis; // (0.0,1.0,0.0)
960  static const ON_3dVector ZAxis; // (0.0,0.0,1.0)
961  static const ON_3dVector UnsetVector; // (ON_UNSET_VALUE,ON_UNSET_VALUE,ON_UNSET_VALUE)
962 
963  // Description:
964  // A index driven function to get unit axis vectors.
965  // Parameters:
966  // index - [in] 0 returns (1,0,0), 1 returns (0,1,0),
967  // 2 returns (0,0,1)
968  // Returns:
969  // Unit 3d vector with vector[i] = (i==index)?1:0;
970  static const ON_3dVector& UnitVector(
971  int // index
972  );
973 
974  // use implicit destructor, copy constructor
975  ON_3dVector(); // x,y,z not initialized
976  ON_3dVector(double x,double y,double z);
977  ON_3dVector(const ON_2dVector& ); // from 2d vector
978  ON_3dVector(const ON_2dPoint& ); // from 2d point
979  ON_3dVector(const ON_3dPoint& ); // from 3d point
980  ON_3dVector(const double*); // from double[3] array
981 
982  ON_3dVector(const ON_2fVector& ); // from 2f vector
983  ON_3dVector(const ON_3fVector& ); // from 3f vector
984  ON_3dVector(const ON_2fPoint& ); // from 2f point
985  ON_3dVector(const ON_3fPoint& ); // from 3f point
986  ON_3dVector(const float*); // from float[3] array
987 
988  // (double*) conversion operators
989  operator double*();
990  operator const double*() const;
991 
992  // use implicit operator=(const ON_3dVector&)
993  ON_3dVector& operator=(const ON_2dVector&);
994  ON_3dVector& operator=(const ON_2dPoint&);
995  ON_3dVector& operator=(const ON_3dPoint&);
996  ON_3dVector& operator=(const double*); // vector = double[3] support
997 
998  ON_3dVector& operator=(const ON_2fVector&);
999  ON_3dVector& operator=(const ON_3fVector&);
1000  ON_3dVector& operator=(const ON_2fPoint&);
1001  ON_3dVector& operator=(const ON_3fPoint&);
1002  ON_3dVector& operator=(const float*); // vector = float[3] support
1003 
1004  ON_3dVector operator-() const;
1005 
1006  ON_3dVector& operator*=(double);
1007  ON_3dVector& operator/=(double);
1008  ON_3dVector& operator+=(const ON_3dVector&);
1009  ON_3dVector& operator-=(const ON_3dVector&);
1010  // DO NOT ADD ANY MORE overrides of += or -=
1011 
1012  double operator*(const ON_3dVector&) const; // inner (dot) product
1013  double operator*(const ON_3dPoint&) const; // inner (dot) product
1014  double operator*(const ON_3fVector&) const; // inner (dot) product
1015 
1016  ON_3dVector operator*(int) const;
1017  ON_3dVector operator/(int) const;
1018  ON_3dVector operator*(float) const;
1019  ON_3dVector operator/(float) const;
1020  ON_3dVector operator*(double) const;
1021  ON_3dVector operator/(double) const;
1022 
1023  ON_3dVector operator+(const ON_3dVector&) const;
1024  ON_3dPoint operator+(const ON_3dPoint&) const;
1025  ON_3dVector operator-(const ON_3dVector&) const;
1026  ON_3dPoint operator-(const ON_3dPoint&) const;
1027  ON_3dVector operator+(const ON_2dVector&) const;
1028  ON_3dPoint operator+(const ON_2dPoint&) const;
1029  ON_3dVector operator-(const ON_2dVector&) const;
1030  ON_3dPoint operator-(const ON_2dPoint&) const;
1031 
1032  ON_3dVector operator+(const ON_3fVector&) const;
1033  ON_3dPoint operator+(const ON_3fPoint&) const;
1034  ON_3dVector operator-(const ON_3fVector&) const;
1035  ON_3dPoint operator-(const ON_3fPoint&) const;
1036  ON_3dVector operator+(const ON_2fVector&) const;
1037  ON_3dPoint operator+(const ON_2fPoint&) const;
1038  ON_3dVector operator-(const ON_2fVector&) const;
1039  ON_3dPoint operator-(const ON_2fPoint&) const;
1040 
1041  double operator*(const ON_4dPoint&) const;
1042  ON_3dVector operator*(const ON_Xform&) const;
1043 
1044  bool operator==(const ON_3dVector&) const;
1045  bool operator!=(const ON_3dVector&) const;
1046 
1047  // dictionary order comparisons
1048  bool operator<=(const ON_3dVector&) const;
1049  bool operator>=(const ON_3dVector&) const;
1050  bool operator<(const ON_3dVector&) const;
1051  bool operator>(const ON_3dVector&) const;
1052 
1053  // index operators mimic double[3] behavior
1054  double& operator[](int);
1055  double operator[](int) const;
1056  double& operator[](unsigned int);
1057  double operator[](unsigned int) const;
1058 
1059  /*
1060  Returns:
1061  False if any coordinate is infinte, a nan, or ON_UNSET_VALUE.
1062  */
1063  bool IsValid() const;
1064 
1065  /*
1066  Returns:
1067  True if every coordinate is ON_UNSET_VALUE.
1068  */
1069  bool IsUnsetVector() const;
1070 
1071  // set 3d vector value
1072  void Set(double x,double y,double z);
1073 
1074  int MaximumCoordinateIndex() const;
1075  double MaximumCoordinate() const; // absolute value of maximum coordinate
1076 
1077  int MinimumCoordinateIndex() const;
1078  double MinimumCoordinate() const; // absolute value of minimum coordinate
1079 
1080  double LengthSquared() const;
1081  double Length() const;
1082 
1083  bool Decompose( // Computes a, b, c such that this vector = a*X + b*Y + c*Z
1084  // Returns false if unable to solve for a,b,c. This happens
1085  // when X,Y,Z is not really a basis.
1086  //
1087  // If X,Y,Z is known to be an orthonormal frame,
1088  // then a = V*X, b = V*Y, c = V*Z will compute
1089  // the same result more quickly.
1090  const ON_3dVector&, // X
1091  const ON_3dVector&, // Y
1092  const ON_3dVector&, // Z
1093  double*, // a
1094  double*, // b
1095  double* // c
1096  ) const;
1097 
1098  int IsParallelTo(
1099  // returns 1: this and other vectors are parallel
1100  // -1: this and other vectors are anti-parallel
1101  // 0: this and other vectors are not parallel
1102  // or at least one of the vectors is zero
1103  const ON_3dVector& other, // other vector
1104  double angle_tolerance = ON_DEFAULT_ANGLE_TOLERANCE // optional angle tolerance (radians)
1105  ) const;
1106 
1107  bool IsPerpendicularTo(
1108  // returns true: this and other vectors are perpendicular
1109  // false: this and other vectors are not perpendicular
1110  // or at least one of the vectors is zero
1111  const ON_3dVector& other, // other vector
1112  double angle_tolerance = ON_DEFAULT_ANGLE_TOLERANCE // optional angle tolerance (radians)
1113  ) const;
1114 
1115  double Fuzz( double tolerance = ON_ZERO_TOLERANCE ) const; // tolerance to use when comparing 3d vectors
1116 
1117  void Zero(); // set all coordinates to zero;
1118  void Reverse(); // negate all coordinates
1119  bool Unitize(); // returns false if vector has zero length
1120  double LengthAndUnitize(); // unitizes and returns initial length
1121 
1122  // Description:
1123  // Test a vector to see if it is very short
1124  //
1125  // Parameters:
1126  // tiny_tol - [in] (default = ON_ZERO_TOLERANCE) a nonzero
1127  // value used as the coordinate zero tolerance.
1128  //
1129  // Returns:
1130  // ( fabs(x) <= tiny_tol && fabs(y) <= tiny_tol && fabs(z) <= tiny_tol )
1131  //
1132  bool IsTiny(
1133  double tiny_tol = ON_ZERO_TOLERANCE // tiny_tol
1134  ) const;
1135 
1136  // Returns:
1137  // true if vector is the zero vector.
1138  bool IsZero() const;
1139 
1140  // Returns:
1141  // true if vector is valid and has length 1.
1142  bool IsUnitVector() const;
1143 
1144  // set this vector to be perpendicular to another vector
1145  bool PerpendicularTo( // Result is not unitized.
1146  // returns false if input vector is zero
1147  const ON_3dVector&
1148  );
1149 
1150  // set this vector to be perpendicular to a plane defined by 3 points
1151  bool PerpendicularTo(
1152  // about 3 times slower than
1153  // ON_3dVector N = ON_CrossProduct(P1-P0,P2-P0);
1154  // N.Unitize();
1155  // returns false if points are coincident or colinear
1156  const ON_3dPoint&, const ON_3dPoint&, const ON_3dPoint&
1157  );
1158 
1159  // These transform the vector in place. The transformation matrix acts on
1160  // the left of the vector; i.e., result = transformation*vector
1161  void Transform(
1162  const ON_Xform& // can use ON_Xform here
1163  );
1164 
1165  void Rotate(
1166  double angle, // angle in radians
1167  const ON_3dVector& axis // axis of rotation
1168  );
1169 
1170  void Rotate(
1171  double sin_angle, // sin(angle)
1172  double cos_angle, // cos(angle)
1173  const ON_3dVector& axis // axis of rotation
1174  );
1175 };
1176 
1177 class PCL_EXPORTS ON_CLASS ON_3dRay
1178 {
1179 public:
1180  ON_3dRay();
1181  ~ON_3dRay();
1182 
1185 };
1186 
1187 /*
1188 Description:
1189  Typically the vector portion is a unit vector and
1190  m_d = -(x*P.x + y*P.y + z*P.z) for a point P on the plane.
1191 */
1193 {
1194 public:
1195  // C++ defaults for construction, destruction, copys, and operator=
1196  // work fine.
1197 
1198  static const ON_PlaneEquation UnsetPlaneEquation; // (ON_UNSET_VALUE,ON_UNSET_VALUE,ON_UNSET_VALUE,ON_UNSET_VALUE)
1199  static const ON_PlaneEquation ZeroPlaneEquation; // (0.0,0.0,0.0,0.0)
1200 
1201  ON_PlaneEquation();
1202 
1203  ON_PlaneEquation(double xx, double yy, double zz, double dd);
1204 
1205  /*
1206  Description:
1207  returns true if x, y, z, d are valid, finite doubles.
1208  Remarks:
1209  this function will return true if x, y and z are all zero.
1210  See Also:
1211  ON_PlaneEquation::IsSet().
1212  */
1213  bool IsValid() const;
1214 
1215  /*
1216  Description:
1217  returns true if x, y, z, d are valid, finite doubles and
1218  at least one of x, y or z is not zero.
1219  */
1220  bool IsSet() const;
1221 
1222  /*
1223  Description:
1224  Sets (x,y,z) to a unitized N and then sets
1225  d = -(x*P.x + y*P.y + z*P.z).
1226  Parameters:
1227  P - [in] point on the plane
1228  N - [in] vector perpendicular to the plane
1229  Returns:
1230  true if input is valid.
1231  */
1232  bool Create( ON_3dPoint P, ON_3dVector N );
1233 
1234  /*
1235  Description:
1236  Evaluate the plane at a point.
1237  Parameters:
1238  P - [in]
1239  Returns:
1240  x*P.x + y*P.y + z*P.z + d;
1241  */
1242  double ValueAt(ON_3dPoint P) const;
1243  double ValueAt(ON_4dPoint P) const;
1244  double ValueAt(ON_3dVector P) const;
1245  double ValueAt(double x, double y, double z) const;
1246 
1247  /*
1248  Description:
1249  Evaluate the plane at a list of point values.
1250  Parameters:
1251  Pcount - [in]
1252  number of points
1253  P - [in]
1254  points
1255  value - [in]
1256  If not null, value[] must be an array of length at least Pcount.
1257  The values will be stored in this array. If null, the an array
1258  will be allocated with onmalloc() and returned.
1259  value_range - [out]
1260  If not null, the range of values will be returned here.
1261  Returns:
1262  An array of Pcount values. If the input parameter value was null,
1263  then the array is allocated on the heap using onmalloc() and the
1264  caller is responsible for calling onfree() when finished. If the
1265  input is not valid, null is returned.
1266  */
1267  double* ValueAt(
1268  int Pcount,
1269  const ON_3fPoint* P,
1270  double* value,
1271  double value_range[2]
1272  ) const;
1273 
1274  double* ValueAt(
1275  int Pcount,
1276  const ON_3dPoint* P,
1277  double* value,
1278  double value_range[2]
1279  ) const;
1280 
1281  /*
1282  Description:
1283  This function calculates and evalutes points that
1284  would be exactly on the plane if double precision
1285  aritmetic were mathematically perfect and returns
1286  the largest value of the evaluations.
1287  */
1288  double ZeroTolerance() const;
1289 
1290  /*
1291  Description:
1292  Transform the plane equation so that, if e0 is the initial
1293  equation, e1 is transformed equation and P is a point,
1294  then e0.ValueAt(P) = e1.ValueAt(xform*P).
1295  Parameters:
1296  xform - [in]
1297  Invertable transformation.
1298  Returns:
1299  True if the plane equation was successfully transformed.
1300  False if xform is not invertable or the equation is not
1301  valid.
1302  Remarks:
1303  This function has to invert xform. If you have apply the
1304  same transformation to a bunch of planes, then it will be
1305  more efficient to calculate xform's inverse transpose
1306  and apply the resultingt transformation to the equation's
1307  coefficients as if they were 4d point coordinates.
1308  */
1309  bool Transform( const ON_Xform& xform );
1310 
1311  /*
1312  Description:
1313  Get point on plane that is closest to a given point.
1314  Parameters:
1315  point - [in]
1316  Returns:
1317  A 3d point on the plane that is closest to the input point.
1318  */
1319  ON_3dPoint ClosestPointTo( ON_3dPoint point ) const;
1320 
1321  /*
1322  Description:
1323  Get the minimum value of the plane equation
1324  on a bounding box.
1325  Parameters:
1326  bbox - [in]
1327  Returns:
1328  Minimum value of the plane equation on the bounding box.
1329  */
1330  double MinimumValueAt(const ON_BoundingBox& bbox) const;
1331 
1332  /*
1333  Description:
1334  Get the maximum value of the plane equation
1335  on a bounding box.
1336  Parameters:
1337  bbox - [in]
1338  Returns:
1339  Maximum value of the plane equation on the bounding box.
1340  */
1341  double MaximumValueAt(const ON_BoundingBox& bbox) const;
1342 
1343  /*
1344  Description:
1345  Get the maximum value of the plane equation on a set of 3d points.
1346  Parameters:
1347  bRational - [in]
1348  False if the points are euclidean (x,y,z)
1349  True if the points are homogenous rational (x,y,z,w)
1350  (x/w,y/w,z/w) is used to evaluate the value.
1351  point_count - [in]
1352  point_stride - [in]
1353  i-th point's x coordinate = points[i*point_stride]
1354  points - [in]
1355  coordinates of points
1356  stop_value - [in]
1357  If stop_value is valid and not ON_UNSET_VALUE, then the
1358  evaulation stops if a value > stop_value is found.
1359  If stop_value = ON_UNSET_VALUE, then stop_value is ignored.
1360  Returns:
1361  Maximum value of the plane equation on the point list.
1362  If the input is not valid, then ON_UNSET_VALUE is returned.
1363  */
1364  double MaximumValueAt(
1365  bool bRational,
1366  int point_count,
1367  int point_stride,
1368  const double* points,
1369  double stop_value
1370  ) const;
1371 
1372  /*
1373  Description:
1374  Get the minimum value of the plane equation on a set of 3d points.
1375  Parameters:
1376  bRational - [in]
1377  False if the points are euclidean (x,y,z)
1378  True if the points are homogenous rational (x,y,z,w)
1379  (x/w,y/w,z/w) is used to evaluate the value.
1380  point_count - [in]
1381  point_stride - [in]
1382  i-th point's x coordinate = points[i*point_stride]
1383  points - [in]
1384  coordinates of points
1385  stop_value - [in]
1386  If stop_value is valid and not ON_UNSET_VALUE, then the
1387  evaulation stops if a value < stop_value is found.
1388  If stop_value = ON_UNSET_VALUE, then stop_value is ignored.
1389  Returns:
1390  Maximum value of the plane equation on the point list.
1391  If the input is not valid, then ON_UNSET_VALUE is returned.
1392  */
1393  double MinimumValueAt(
1394  bool bRational,
1395  int point_count,
1396  int point_stride,
1397  const double* points,
1398  double stop_value
1399  ) const;
1400 
1401  /*
1402  Description:
1403  Get the maximum absolute value of the plane equation
1404  on a set of 3d points.
1405  Parameters:
1406  bRational - [in]
1407  False if the points are euclidean (x,y,z)
1408  True if the points are homogenous rational (x,y,z,w)
1409  (x/w,y/w,z/w) is used to evaluate the value.
1410  point_count - [in]
1411  point_stride - [in]
1412  i-th point's x coordinate = points[i*point_stride]
1413  points - [in]
1414  coordinates of points
1415  stop_value - [in]
1416  If stop_value >= 0.0, then the evaulation stops if an
1417  absolute value > stop_value is found. If stop_value < 0.0
1418  or stop_value is invalid, then stop_value is ignored.
1419  Returns:
1420  Maximum value of the plane equation on the point list.
1421  If the input is not valid, then ON_UNSET_VALUE is returned.
1422  */
1423  double MaximumAbsoluteValueAt(
1424  bool bRational,
1425  int point_count,
1426  int point_stride,
1427  const double* points,
1428  double stop_value
1429  ) const;
1430 
1431  /*
1432  Description:
1433  Test points on a bezier curve to see if they are near the plane.
1434  Parameters:
1435  bezcrv - [in]
1436  s0 - [in]
1437  s1 - [in] the interval from s0 to s1 is tested (s0 < s1)
1438  sample_count - [in] number of interior points to test.
1439  Numbers like 1, 3, 7, 15, ... work best.
1440  endpoint_tolerance - [in] If >= 0, then the end points are
1441  tested to see if the distance from the endpoints
1442  is <= endpoint_tolerance.
1443  interior_tolerance - [in] (>=0 and >=endpoint_tolerance)
1444  This tolerance is used to test the interior sample points.
1445  smin - [put] If not NULL, *smin = bezier parameter of nearest
1446  test point.
1447  smax - [put] If not NULL, *smax = bezier parameter of farthest
1448  test point. If false is returned, this is the
1449  parameter of the test point that failed.
1450  Returns:
1451  True if all the tested points passed the tolerance test.
1452  False if at least one tested point failed the tolerance test.
1453  (The test terminates when the first failure is encountered.)
1454  */
1455  bool IsNearerThan(
1456  const class ON_BezierCurve& bezcrv,
1457  double s0,
1458  double s1,
1459  int sample_count,
1460  double endpoint_tolerance,
1461  double interior_tolerance,
1462  double* smin,
1463  double* smax
1464  ) const;
1465 
1466  bool operator==(const ON_PlaneEquation&) const;
1467  bool operator!=(const ON_PlaneEquation&) const;
1468 
1469  double d; // 4th coefficient of the plane equation.
1470 };
1471 
1472 ON_DECL
1473 ON_3dVector operator*(int, const ON_3dVector&);
1474 
1475 ON_DECL
1476 ON_3dVector operator*(float, const ON_3dVector&);
1477 
1478 ON_DECL
1479 ON_3dVector operator*(double, const ON_3dVector&);
1480 
1481 ///////////////////////////////////////////////////////////////
1482 //
1483 // ON_3dVector utilities
1484 //
1485 
1486 ON_DECL
1487 double
1488 ON_DotProduct(
1489  const ON_3dVector&,
1490  const ON_3dVector&
1491  );
1492 
1493 
1494 ON_DECL
1495 ON_3dVector
1496 ON_CrossProduct(
1497  const ON_3dVector&,
1498  const ON_3dVector&
1499  );
1500 
1501 ON_DECL
1502 ON_3dVector
1503 ON_CrossProduct( // 3d cross product for old fashioned arrays
1504  const double*, // array of 3d doubles
1505  const double* // array of 3d doubles
1506  );
1507 
1508 ON_DECL
1509 double
1510 ON_TripleProduct(
1511  const ON_3dVector&,
1512  const ON_3dVector&,
1513  const ON_3dVector&
1514  );
1515 
1516 ON_DECL
1517 double
1518 ON_TripleProduct( // 3d triple product for old fashioned arrays
1519  const double*, // array of 3d doubles
1520  const double*, // array of 3d doubles
1521  const double* // array of 3d doubles
1522  );
1523 
1524 ON_DECL
1525 bool
1526 ON_IsOrthogonalFrame( // true if X, Y, Z are nonzero and mutually perpendicular
1527  const ON_3dVector&, // X
1528  const ON_3dVector&, // Y
1529  const ON_3dVector& // Z
1530  );
1531 
1532 ON_DECL
1533 bool
1534 ON_IsOrthonormalFrame( // true if X, Y, Z are orthogonal and unit length
1535  const ON_3dVector&, // X
1536  const ON_3dVector&, // Y
1537  const ON_3dVector& // Z
1538  );
1539 
1540 ON_DECL
1541 bool
1542 ON_IsRightHandFrame( // true if X, Y, Z are orthonormal and right handed
1543  const ON_3dVector&, // X
1544  const ON_3dVector&, // Y
1545  const ON_3dVector& // Z
1546  );
1547 
1548 ///////////////////////////////////////////////////////////////
1549 //
1550 // common points and vectors
1551 //
1552 // ON_unset_point is obsolete - use ON_3dPoint::UnsetPoint
1553 #define ON_unset_point ON_UNSET_POINT
1554 
1555 // ON_UNSET_POINT is OBSOLETE - use ON_3dPoint::UnsetPoint
1556 extern ON_EXTERN_DECL const ON_3dPoint ON_UNSET_POINT; // (ON_UNSET_VALUE,ON_UNSET_VALUE,ON_UNSET_VALUE)
1557 
1558 // ON_UNSET_VECTOR is OBSOLETE - use ON_3dPoint::UnsetVector
1559 extern ON_EXTERN_DECL const ON_3dVector ON_UNSET_VECTOR; // (ON_UNSET_VALUE,ON_UNSET_VALUE,ON_UNSET_VALUE)
1560 
1561 // ON_origin is OBSOLETE - use ON_3dPoint::Origin
1562 extern ON_EXTERN_DECL const ON_3dPoint ON_origin; // (0.0, 0.0, 0.0)
1563 
1564 // ON_xaxis is OBSOLETE - use ON_3dPoint::XAxis
1565 extern ON_EXTERN_DECL const ON_3dVector ON_xaxis; // (1.0, 0.0, 0.0)
1566 
1567 // ON_yaxis is OBSOLETE - use ON_3dPoint::YAxis
1568 extern ON_EXTERN_DECL const ON_3dVector ON_yaxis; // (0.0, 1.0, 0.0)
1569 
1570 // ON_zaxis is OBSOLETE - use ON_3dPoint::ZAxis
1571 extern ON_EXTERN_DECL const ON_3dVector ON_zaxis; // (0.0, 0.0, 1.0)
1572 
1573 #include "opennurbs_fpoint.h"
1574 
1575 ////////////////////////////////////////////////////////////////
1576 //
1577 // ON_SurfaceCurvature
1578 //
1580 {
1581 public:
1582  double k1, k2; // principal curvatures
1583 
1584  double GaussianCurvature() const;
1585  double MeanCurvature() const;
1586  double MinimumRadius() const;
1587  double MaximumRadius() const;
1588 };
1589 
1590 #endif
1591 
double operator*(const ON_3dVector &) const
static const ON_3dVector YAxis
static const ON_2dPoint Origin
bool IsValid() const
static const ON_3dVector XAxis
static const ON_3dVector ZAxis
static const ON_3dVector ZeroVector
static const ON_2dVector YAxis
static const ON_2dVector XAxis
static const ON_3dPoint Origin
ON_3dPoint m_P
static const ON_3dPoint UnsetPoint
static const ON_PlaneEquation UnsetPlaneEquation
static const ON_PlaneEquation ZeroPlaneEquation
bool operator!=(const ON_3dVector &) const
static const ON_Interval EmptyInterval
void Transform(const ON_Xform &)
static const ON_2dPoint UnsetPoint
static const ON_3dVector UnsetVector
bool operator==(const ON_3dVector &) const
static const ON_2dVector UnsetVector
Definition: norms.h:54
static const ON_2dVector ZeroVector
#define PCL_EXPORTS
Definition: pcl_macros.h:241
ON_3dVector m_V