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