Open Inventor Reference
SbLineard.h
Go to the documentation of this file.
1/*
2 *
3 * Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * Further, this software is distributed without any warranty that it is
16 * free of the rightful claim of any third person regarding infringement
17 * or the like. Any license provided herein, whether implied or
18 * otherwise, applies only to this software file. Patent licenses, if
19 * any, provided herein do not apply to combinations of this program with
20 * other software, or any other product whatsoever.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
27 * Mountain View, CA 94043, or:
28 *
29 * http://www.sgi.com
30 *
31 * For further information regarding this notice, see:
32 *
33 * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
34 *
35 */
36
37
38/*
39 * Copyright (C) 1990,91 Silicon Graphics, Inc.
40 *
41 _______________________________________________________________________
42 ______________ S I L I C O N G R A P H I C S I N C . ____________
43 |
44 | $Revision: 1.3 $
45 |
46 | Description:
47 | This file contains definitions of various linear algebra classes,
48 | such as vectors, coordinates, etc..
49 |
50 | Classes:
51 | SbVec3d
52 | SbVec2d
53 | SbVec4d
54 | SbRotationd
55 | SbMatrixd
56 |
57 | SbLined
58 | SbPlaned
59 | SbSphered
60 |
61 | Author(s) : originally by Paul S. Strauss, Nick Thompson,
62 | David Mott, Alain Dumesny
63 | adapted for double types by Wolf Spindler
64 |
65 ______________ S I L I C O N G R A P H I C S I N C . ____________
66 _______________________________________________________________________
67 */
68
69#ifndef _SB_LINEARD_
70#define _SB_LINEARD_
71
73#include <math.h>
74#include <Inventor/SbBasic.h>
75
81
82typedef double SbMatd[4][4];
83
84class SbVec3d;
85class SbVec2d;
86class SbVec4d;
87class SbRotationd;
88class SbMatrixd;
89
90class SbLined;
91class SbPlaned;
92class SbCylinderd;
93class SbSphered;
94
96class SbBox3d;
97
98
99
100
103
115
117 public:
118
120 SbVec3d() { vec[0] = 0.; vec[1] = 0.; vec[2] = 0.; }
121
123 SbVec3d(const double v[3])
124 { vec[0] = v[0]; vec[1] = v[1]; vec[2] = v[2]; }
125
127 SbVec3d(double x, double y, double z)
128 { vec[0] = x; vec[1] = y; vec[2] = z; }
129
132
134 SbVec3d cross(const SbVec3d &v) const;
135
137 double dot(const SbVec3d &v) const;
138
140 const double *getValue() const { return vec; }
141
143 void getValue(double &x, double &y, double &z) const;
144
146 double length() const;
147
149 double normalize();
150
152 void negate();
153
155 SbVec3d & setValue(const double v[3])
156 { vec[0] = v[0]; vec[1] = v[1]; vec[2] = v[2]; return *this; }
157
159 SbVec3d & setValue(double x, double y, double z)
160 { vec[0] = x; vec[1] = y; vec[2] = z; return *this; }
161
164 SbVec3d & setValue(const SbVec3d &barycentic,
165 const SbVec3d &v0, const SbVec3d &v1, const SbVec3d &v2);
166
168 double & operator [](int i) { return (vec[i]); }
169 const double & operator [](int i) const { return (vec[i]); }
170
172 SbVec3d & operator *=(double d);
173
175 SbVec3d & operator /=(double d)
176 { return *this *= (1.0 / d); }
177
179 SbVec3d & operator +=(SbVec3d v);
181 SbVec3d & operator -=(SbVec3d v);
182
185
187 friend INVENTOR_API SbVec3d operator *(const SbVec3d &v, double d);
188 friend INVENTOR_API SbVec3d operator *(double d, const SbVec3d &v);
189 friend INVENTOR_API SbVec3d operator /(const SbVec3d &v, double d);
190
192 friend INVENTOR_API SbVec3d operator +(const SbVec3d &v1, const SbVec3d &v2);
193
194 friend INVENTOR_API SbVec3d operator -(const SbVec3d &v1, const SbVec3d &v2);
195
197 friend INVENTOR_API bool operator ==(const SbVec3d &v1, const SbVec3d &v2);
198 friend INVENTOR_API bool operator !=(const SbVec3d &v1, const SbVec3d &v2);
199
202 bool equals(const SbVec3d v, double tolerance) const;
203
207
208 protected:
209 double vec[3];
210};
211
213inline INVENTOR_API SbVec3d operator *(double d, const SbVec3d &v)
214{ return v * d; }
215inline INVENTOR_API SbVec3d operator /(const SbVec3d &v, double d)
216{ return v * (1.0 / d); }
217
220
221INVENTOR_API bool operator ==(const SbVec3d &v1, const SbVec3d &v2);
222inline INVENTOR_API bool operator !=(const SbVec3d &v1, const SbVec3d &v2)
223{ return !(v1 == v2); }
224
225
226
229
241
243 public:
244
246 SbVec2d() { vec[0] = 0.; vec[1] = 0.; }
247
249 SbVec2d(const double v[2]) { setValue(v); }
250
252 SbVec2d(double x, double y) { setValue(x, y); }
253
255 double dot(const SbVec2d &v) const;
256
258 const double *getValue() const { return vec; }
259
261 void getValue(double &x, double &y) const;
262
264 double length() const;
265
267 void negate();
268
270 double normalize();
271
273 SbVec2d & setValue(const double v[2]);
274
276 SbVec2d & setValue(double x, double y);
277
279 double & operator [](int i) { return (vec[i]); }
280 const double & operator [](int i) const { return (vec[i]); }
281
283 SbVec2d & operator *=(double d);
284
286 SbVec2d & operator /=(double d)
287 { return *this *= (1.0 / d); }
288
290 SbVec2d & operator +=(const SbVec2d &u);
292 SbVec2d & operator -=(const SbVec2d &u);
293
296
298 friend INVENTOR_API SbVec2d operator *(const SbVec2d &v, double d);
299 friend INVENTOR_API SbVec2d operator *(double d, const SbVec2d &v);
300 friend INVENTOR_API SbVec2d operator /(const SbVec2d &v, double d);
301
303 friend INVENTOR_API SbVec2d operator +(const SbVec2d &v1, const SbVec2d &v2);
304
305 friend INVENTOR_API SbVec2d operator -(const SbVec2d &v1, const SbVec2d &v2);
306
308 friend INVENTOR_API bool operator ==(const SbVec2d &v1, const SbVec2d &v2);
309 friend INVENTOR_API bool operator !=(const SbVec2d &v1, const SbVec2d &v2);
310
313 bool equals(const SbVec2d v, double tolerance) const;
314
315 protected:
316 double vec[2];
317};
318
320inline INVENTOR_API SbVec2d operator *(double d, const SbVec2d &v)
321{ return v * d; }
322inline INVENTOR_API SbVec2d operator /(const SbVec2d &v, double d)
323{ return v * (1.0 / d); }
324
327
328INVENTOR_API bool operator ==(const SbVec2d &v1, const SbVec2d &v2);
329inline INVENTOR_API bool operator !=(const SbVec2d &v1, const SbVec2d &v2)
330{ return !(v1 == v2); }
331
332
333
336
348
350 public:
351
353 SbVec4d() { vec[0] = 0.; vec[1] = 0.; vec[2] = 0.; vec[3] = 0.; }
354
356 SbVec4d(const double v[4]) { setValue(v); }
357
359 SbVec4d(double x, double y, double z, double w) { setValue(x, y, z, w); }
360
362 double dot(const SbVec4d &v) const;
363
365 void getReal(SbVec3d &v) const;
366
368 SbVec3d getReal() const { SbVec3d tmp; getReal(tmp); return tmp; }
369
371 const double *getValue() const { return vec; }
372
374 void getValue(double &x, double &y, double &z, double &w) const;
375
377 double length() const;
378
380 void negate();
381
383 double normalize();
384
386 SbVec4d & setValue(const double v[4]);
387
389 SbVec4d & setValue(double x, double y, double z, double w);
390
392 double & operator [](int i) { return (vec[i]); }
393 const double & operator [](int i) const { return (vec[i]); }
394
396 SbVec4d & operator *=(double d);
397
399 SbVec4d & operator /=(double d)
400 { return *this *= (1.0 / d); }
401
403 SbVec4d & operator +=(const SbVec4d &u);
405 SbVec4d & operator -=(const SbVec4d &u);
406
409
411 friend INVENTOR_API SbVec4d operator *(const SbVec4d &v, double d);
412 friend INVENTOR_API SbVec4d operator *(double d, const SbVec4d &v);
413 friend INVENTOR_API SbVec4d operator /(const SbVec4d &v, double d);
414
416 friend INVENTOR_API SbVec4d operator +(const SbVec4d &v1, const SbVec4d &v2);
417
418 friend INVENTOR_API SbVec4d operator -(const SbVec4d &v1, const SbVec4d &v2);
419
421 friend INVENTOR_API bool operator ==(const SbVec4d &v1, const SbVec4d &v2);
422 friend INVENTOR_API bool operator !=(const SbVec4d &v1, const SbVec4d &v2);
423
426 bool equals(const SbVec4d v, double tolerance) const;
427
428 protected:
429 double vec[4];
430};
431
433inline INVENTOR_API SbVec4d operator *(double d, const SbVec4d &v)
434{ return v * d; }
435inline INVENTOR_API SbVec4d operator /(const SbVec4d &v, double d)
436{ return v * (1.0 / d); }
437
440
441INVENTOR_API bool operator ==(const SbVec4d &v1, const SbVec4d &v2);
442inline INVENTOR_API bool operator !=(const SbVec4d &v1, const SbVec4d &v2)
443{ return !(v1 == v2); }
444
445
446
449
466
468 public:
469
472 {
473 quat[0] = 0.; quat[1] = 0.; quat[2] = 0.; quat[3] = 1.;
474 }
475
477 SbRotationd(const double v[4])
478 { setValue(v); }
479
481 SbRotationd(double q0, double q1, double q2, double q3)
482 { setValue(q0, q1, q2, q3); }
483
486 { setValue(m); }
487
489 SbRotationd(const SbVec3d &axis, double radians)
490 { setValue(axis, radians); }
491
501 SbRotationd(const SbVec3d &rotateFrom, const SbVec3d &rotateTo)
502 { setValue(rotateFrom, rotateTo); }
503
505 const double * getValue() const
506 { return (quat); }
507
509 void getValue(double &q0, double &q1,
510 double &q2, double &q3) const;
511
513 void getValue(SbVec3d &axis, double &radians) const;
514
516 void getValue(SbMatrixd &matrix) const;
517
520
522 SbVec3d getAxis() const { SbVec3d axis; double radians; getValue(axis, radians); return axis; }
524 double getAngle() const { SbVec3d axis; double radians; getValue(axis, radians); return radians; }
525
528
531 { SbRotationd q = *this; return q.invert(); }
532
534 SbRotationd & setValue(const double q[4]);
535
537 SbRotationd & setValue(double q0, double q1, double q2, double q3);
538
541
543 SbRotationd & setValue(const SbVec3d &axis, double radians);
544
546 SbRotationd & setValue(const SbVec3d &rotateFrom,
547 const SbVec3d &rotateTo);
548
550 SbRotationd & operator *=(const SbRotationd &q);
551
553 friend INVENTOR_API bool operator ==(const SbRotationd &q1, const SbRotationd &q2);
554 friend INVENTOR_API bool operator !=(const SbRotationd &q1, const SbRotationd &q2);
555
558 bool equals(const SbRotationd &r, double tolerance) const;
559
562
564 void multVec(const SbVec3d &src, SbVec3d &dst) const;
565
567 SbVec3d transformPoint(const SbVec3d &src) const { SbVec3d dst; multVec(src, dst); return dst; }
568
571 void scaleAngle( double scaleFactor );
572
575 static SbRotationd slerp(const SbRotationd &rot0,
576 const SbRotationd &rot1, double t);
577
580 { return SbRotationd(0.0, 0.0, 0.0, 1.0); }
581
582 private:
583 double quat[4];
584
586 double norm() const;
587
589 void normalize();
590};
591
593inline INVENTOR_API bool operator !=(const SbRotationd &q1, const SbRotationd &q2)
594{ return !(q1 == q2); }
595
597
598
599
600
603
615
617 public:
618
621 makeIdentity();
622 }
623
625 SbMatrixd(double a11, double a12, double a13, double a14,
626 double a21, double a22, double a23, double a24,
627 double a31, double a32, double a33, double a34,
628 double a41, double a42, double a43, double a44);
629
631 SbMatrixd(const SbMatd &m);
632
634 void setValue(const SbMatd &m);
635
637 void setValue(const double* data);
638
639 public:
640
643
646
648 void setRotate(const SbRotationd &q);
649
651 void setScale(double s);
652
654 void setScale(const SbVec3d &s);
655
657 void setTranslate(const SbVec3d &t);
658
664 const SbVec3d &translation,
665 const SbRotationd &rotation,
666 const SbVec3d &scaleFactor,
667 const SbRotationd &scaleOrientation,
668 const SbVec3d &center);
671 void setTransform(const SbVec3d &t, const SbRotationd &r,
672 const SbVec3d &s)
673 { setTransform(t, r, s,
674 SbRotationd(0,0,0,1), SbVec3d(0,0,0)); }
675 void setTransform(const SbVec3d &t, const SbRotationd &r,
676 const SbVec3d &s, const SbRotationd &so)
677 { setTransform(t, r, s, so, SbVec3d(0,0,0)); }
678
686 void getTransform(SbVec3d &translation,
687 SbRotationd &rotation,
688 SbVec3d &scaleFactor,
689 SbRotationd &scaleOrientation,
690 const SbVec3d &center) const;
692 SbVec3d &s, SbRotationd &so) const
693 { getTransform(t, r, s, so, SbVec3d(0,0,0)); }
694
695
697
699 void getValue(SbMatd &m) const;
700 const SbMatd & getValue() const { return matrix; }
701
704 double det3(int r1, int r2, int r3, int c1, int c2, int c3) const;
705
707 double det3() const { return det3(0, 1, 2, 0, 1, 2); }
708
710 double det4() const;
711
718 SbVec3d &t, SbMatrixd &proj) const;
719
723
726 bool LUDecomposition(int index[4], double &d);
727
730 void LUBackSubstitution(int index[4], double b[4]) const;
731
734
736 SbMatrixd & multRight(const SbMatrixd &m); // this = this * m
738 SbMatrixd & multLeft(const SbMatrixd &m); // this = m * this
739
741 SbVec3d transformPoint(const SbVec3d &src) const { SbVec3d dst; multVecMatrix(src, dst); return dst; }
743 SbVec4d transformPoint(const SbVec4d &src) const { SbVec4d dst; multVecMatrix(src, dst); return dst; }
744
753 SbVec3d transformDirection(const SbVec3d &src) const { SbVec3d dst; multDirMatrix(src, dst); return dst; }
754
757 SbLined transformLine(const SbLined &src) const;
758
761 void multMatrixVec(const SbVec3d &src, SbVec3d &dst) const;
762
764 void multVecMatrix(const SbVec3d &src, SbVec3d &dst) const;
766 void multVecMatrix(const SbVec4d &src, SbVec4d &dst) const;
768 void multVecMatrix(const SbVec3d &src, SbVec4d &dst) const;
769
778 void multDirMatrix(const SbVec3d &src, SbVec3d &dst) const;
779
782 void multLineMatrix(const SbLined &src, SbLined &dst) const;
783
785 void print(FILE *fp) const;
786
788 operator double *() { return &matrix[0][0]; }
789
791 operator SbMatd &() { return matrix; }
792
794 double * operator [](int i) { return &matrix[i][0]; }
795 const double * operator [](int i) const { return &matrix[i][0]; }
796
798 SbMatrixd & operator =(const SbMatd &m);
799
801 SbMatrixd & operator =(const SbMatrixd &m);
802
804 SbMatrixd & operator =(const SbRotationd &q) { setRotate(q); return *this; }
805
807 SbMatrixd & operator *=(const SbMatrixd &m) { return multRight(m); }
808
811
813 friend INVENTOR_API bool operator ==(const SbMatrixd &m1, const SbMatrixd &m2);
814 friend INVENTOR_API bool operator !=(const SbMatrixd &m1, const SbMatrixd &m2);
815
817 bool equals(const SbMatrixd &m, double tolerance) const;
818
819 private:
820 SbMatd matrix;
821
823 void jacobi3(double evalues[3], SbVec3d evectors[3], int &rots) const;
824
825 bool affine_inverse(const SbMatrixd &in, SbMatrixd &out) const;
826};
827
828
830
831INVENTOR_API bool operator ==(const SbMatrixd &m1, const SbMatrixd &m2);
832inline INVENTOR_API bool operator !=(const SbMatrixd &m1, const SbMatrixd &m2)
833{ return !(m1 == m2); }
834
835
838
851
853 public:
857
860 SbLined(const SbVec3d &p0, const SbVec3d &p1);
861
863 void setValue(const SbVec3d &p0, const SbVec3d &p1);
864
869 bool getClosestPoints(const SbLined &line2,
870 SbVec3d &ptOnThis,
871 SbVec3d &ptOnLine2 ) const;
872
874 SbVec3d getClosestPoint(const SbVec3d &point) const;
875
877 const SbVec3d & getPosition() const { return pos; }
879 const SbVec3d & getDirection() const { return dir; }
880
881
882 SoINTERNAL public:
884 bool intersect( const SbBox3d &box,
885 SbVec3d &enter, SbVec3d &exit ) const;
886 bool intersect( double angle, const SbBox3d &box ) const;
887 bool intersect( double angle, const SbVec3d &point ) const;
888 bool intersect( double angle, const SbVec3d &v0,
889 const SbVec3d &v1, SbVec3d &pt ) const;
890 bool intersect( const SbVec3d &v0,
891 const SbVec3d &v1,
892 const SbVec3d &v2,
893 SbVec3d &pt, SbVec3d &barycentric,
894 bool &front ) const;
895
896 private:
899 SbVec3d pos;
900 SbVec3d dir;
901};
902
903
904
907
919
921 public:
923 SbPlaned() { distance = 0.; }
924
927 SbPlaned(const SbVec3d &p0, const SbVec3d &p1, const SbVec3d &p2);
928
931 SbPlaned(const SbVec3d &n, double d);
932
935 SbPlaned(const SbVec3d &n, const SbVec3d &p);
936
938 void offset(double d);
939
942 bool intersect(const SbLined &l,
943 SbVec3d &intersection) const;
944
946 void transform(const SbMatrixd &matrix);
947
950 bool isInHalfSpace(const SbVec3d &point) const;
951
953 double getDistance(const SbVec3d &point) const;
954
956 const SbVec3d & getNormal() const { return normalVec; }
958 double getDistanceFromOrigin() const { return distance; }
959
961 friend INVENTOR_API bool operator ==(const SbPlaned &p1, const SbPlaned &p2);
962 friend INVENTOR_API bool operator !=(const SbPlaned &p1, const SbPlaned &p2);
963
964 private:
966
968 SbVec3d normalVec;
969
971 double distance;
972};
973
974INVENTOR_API bool operator ==(const SbPlaned &p1, const SbPlaned &p2);
975inline INVENTOR_API bool operator !=(const SbPlaned &p1, const SbPlaned &p2)
976{ return !(p1 == p2); }
977
980
992
994 public:
995
998
1000 SbCylinderd(const SbLined &a, double r);
1001
1003 void setValue(const SbLined &a, double r);
1004
1006 void setAxis(const SbLined &a);
1008 void setRadius(double r);
1009
1011 const SbLined & getAxis() const { return axis; }
1013 double getRadius() const { return radius; }
1014
1016 bool intersect(const SbLined &l, SbVec3d &intersection) const;
1017 bool intersect(const SbLined &l,
1018 SbVec3d &enter, SbVec3d &exit) const;
1019
1020 private:
1021 SbLined axis;
1022 double radius;
1023
1024 static bool unitCylinderIntersect(const SbLined &l,
1025 SbVec3d &in, SbVec3d &out);
1026};
1027
1028
1029
1030
1033
1046
1048 public:
1049
1051 SbSphered() { radius = 0.; }
1052
1054 SbSphered(const SbVec3d &c, double r);
1055
1057 void setValue(const SbVec3d &c, double r);
1058
1060 void setCenter(const SbVec3d &c);
1062 void setRadius(double r);
1063
1065 const SbVec3d & getCenter() const { return center; }
1067 double getRadius() const { return radius; }
1068
1070 void circumscribe(const SbBox3d &box);
1071
1073 bool intersect(const SbLined &l, SbVec3d &intersection) const;
1074 bool intersect(const SbLined &l, SbVec3d &enter, SbVec3d &exit) const;
1075
1076 private:
1077 SbVec3d center;
1078 double radius;
1079};
1080
1081#endif /* _SB_LINEARD_ */
#define SoINTERNAL
Definition SbBasic.h:155
INVENTOR_API bool operator!=(const SbBox3f &b1, const SbBox3f &b2)
Definition SbBox.h:207
INVENTOR_API bool operator==(const SbBox3f &b1, const SbBox3f &b2)
INVENTOR_API SbVec3f operator-(const SbVec3f &v1, const SbVec3f &v2)
INVENTOR_API SbVec3f operator/(const SbVec3f &v, float d)
Definition SbLinear.h:219
INVENTOR_API SbVec3f operator*(const SbVec3f &v, float d)
INVENTOR_API SbVec3f operator+(const SbVec3f &v1, const SbVec3f &v2)
INVENTOR_API SbVec3d operator/(const SbVec3d &v, double d)
Definition SbLineard.h:215
INVENTOR_API bool operator!=(const SbVec3d &v1, const SbVec3d &v2)
Definition SbLineard.h:222
double SbMatd[4][4]
Definition SbLineard.h:82
INVENTOR_API SbVec3d operator-(const SbVec3d &v1, const SbVec3d &v2)
INVENTOR_API bool operator==(const SbVec3d &v1, const SbVec3d &v2)
INVENTOR_API SbVec3d operator*(const SbVec3d &v, double d)
INVENTOR_API SbVec3d operator+(const SbVec3d &v1, const SbVec3d &v2)
#define INVENTOR_API
Disable some annoying warnings on MSVC 6.
Definition SbSystem.h:77
3D box class.
Definition SbBoxd.h:82
Class for representing a cylinder with double values.
Definition SbLineard.h:993
void setRadius(double r)
Set just the axis or radius.
double getRadius() const
Return the axis and radius.
Definition SbLineard.h:1013
bool intersect(const SbLined &l, SbVec3d &intersection) const
Intersect line and cylinder, returning TRUE if there is an intersection.
SbCylinderd()
Constructors. One takes an axis and radius.
SbCylinderd(const SbLined &a, double r)
Constructors. One takes an axis and radius.
void setAxis(const SbLined &a)
Set just the axis or radius.
bool intersect(const SbLined &l, SbVec3d &enter, SbVec3d &exit) const
const SbLined & getAxis() const
Return the axis and radius.
Definition SbLineard.h:1011
void setValue(const SbLined &a, double r)
Change the axis and radius.
Directed line in 3D with double values.
Definition SbLineard.h:852
bool intersect(double angle, const SbBox3d &box) const
bool intersect(double angle, const SbVec3d &point) const
SbVec3d getClosestPoint(const SbVec3d &point) const
Returns the closest point on the line to the given point.
SbLined(const SbVec3d &p0, const SbVec3d &p1)
Constructors.
bool getClosestPoints(const SbLined &line2, SbVec3d &ptOnThis, SbVec3d &ptOnLine2) const
Finds the two closest points between this line and line2, and loads them into ptOnThis and ptOnLine2.
bool intersect(double angle, const SbVec3d &v0, const SbVec3d &v1, SbVec3d &pt) const
void setValue(const SbVec3d &p0, const SbVec3d &p1)
Sets line to pass through points p0 and p1.
const SbVec3d & getDirection() const
Returns position of line origin point and direction vector of line.
Definition SbLineard.h:879
SbLined()
Constructors.
Definition SbLineard.h:856
const SbVec3d & getPosition() const
Returns position of line origin point and direction vector of line.
Definition SbLineard.h:877
bool intersect(const SbBox3d &box, SbVec3d &enter, SbVec3d &exit) const
Intersect the line with a box, point, line, and triangle.
bool intersect(const SbVec3d &v0, const SbVec3d &v1, const SbVec3d &v2, SbVec3d &pt, SbVec3d &barycentric, bool &front) const
4x4 matrix class with double values.
Definition SbLineard.h:616
void multDirMatrix(const SbVec3d &src, SbVec3d &dst) const
Multiplies given row vector by matrix, giving vector result.
void LUBackSubstitution(int index[4], double b[4]) const
Perform back-substitution on LU-decomposed matrix.
SbMatrixd(const SbMatd &m)
Constructors.
SbVec3d transformDirection(const SbVec3d &src) const
Multiplies given row vector by matrix, giving vector result.
Definition SbLineard.h:753
void getTransform(SbVec3d &translation, SbRotationd &rotation, SbVec3d &scaleFactor, SbRotationd &scaleOrientation, const SbVec3d &center) const
Decomposes the matrix into a translation, rotation, scale, and scale orientation.
SbMatrixd & multLeft(const SbMatrixd &m)
Multiplies matrix by given matrix on right or left.
SbMatrixd transpose() const
Returns transpose of matrix.
double det3() const
Returns determinant of upper-left 3x3 submatrix.
Definition SbLineard.h:707
void setTransform(const SbVec3d &translation, const SbRotationd &rotation, const SbVec3d &scaleFactor, const SbRotationd &scaleOrientation, const SbVec3d &center)
Composes the matrix based on a translation, rotation, scale, orientation for scale,...
void getValue(SbMatd &m) const
The following methods return matrix values and other info:
void multVecMatrix(const SbVec4d &src, SbVec4d &dst) const
Multiplies given row vector by matrix, giving vector result. Takes homogenous coordinate and returns ...
void setValue(const double *data)
Sets value from a double array of 16 elements.
void setRotate(const SbRotationd &q)
Sets matrix to rotate by given rotation.
void multVecMatrix(const SbVec3d &src, SbVec3d &dst) const
Multiplies given row vector by matrix, giving vector result. Use this method to transform points from...
const SbMatd & getValue() const
Definition SbLineard.h:700
void makeIdentity()
Sets matrix to be identity.
void setScale(const SbVec3d &s)
Sets matrix to scale by given vector.
void setTransform(const SbVec3d &t, const SbRotationd &r, const SbVec3d &s)
Overloaded methods as a kludge because the compiler won't let us have SbVec3d(0,0,...
Definition SbLineard.h:671
void multVecMatrix(const SbVec3d &src, SbVec4d &dst) const
Multiplies given row vector by matrix, giving vector result. Takes SbVec4(src,1.) coordinate and retu...
static SbMatrixd identity()
Returns an identity matrix.
SbMatrixd()
Default constructor, initialized to identity.
Definition SbLineard.h:620
void setValue(const SbMatd &m)
Sets value from 4x4 array of elements.
bool factor(SbMatrixd &r, SbVec3d &s, SbMatrixd &u, SbVec3d &t, SbMatrixd &proj) const
Factors a matrix m into 5 pieces: m = r s r^ u t, where r^ means transpose of r, and r and u are rota...
void multLineMatrix(const SbLined &src, SbLined &dst) const
Multiplies the given line's origin by the matrix, and the line's direction by the rotation portion of...
void print(FILE *fp) const
Prints a formatted version of the matrix to the given file pointer.
bool LUDecomposition(int index[4], double &d)
Perform in-place LU decomposition of matrix.
void setScale(double s)
Sets matrix to scale by given uniform factor.
SbMatrixd(double a11, double a12, double a13, double a14, double a21, double a22, double a23, double a24, double a31, double a32, double a33, double a34, double a41, double a42, double a43, double a44)
Constructor given all 16 elements in row-major order.
double det3(int r1, int r2, int r3, int c1, int c2, int c3) const
Returns determinant of 3x3 submatrix composed of given row and column indices (0-3 for each).
SbMatrixd inverse() const
Returns inverse of matrix.
double det4() const
Returns determinant of entire matrix.
SbVec4d transformPoint(const SbVec4d &src) const
Multiplies given row vector by matrix, giving vector result. Takes homogenous coordinate and returns ...
Definition SbLineard.h:743
void getTransform(SbVec3d &t, SbRotationd &r, SbVec3d &s, SbRotationd &so) const
Definition SbLineard.h:691
SbLined transformLine(const SbLined &src) const
Multiplies the given line's origin by the matrix, and the line's direction by the rotation portion of...
bool equals(const SbMatrixd &m, double tolerance) const
Equality comparison within given tolerance, for each component.
void setTranslate(const SbVec3d &t)
Sets matrix to translate by given vector.
void setTransform(const SbVec3d &t, const SbRotationd &r, const SbVec3d &s, const SbRotationd &so)
Definition SbLineard.h:675
SbVec3d transformPoint(const SbVec3d &src) const
Multiplies given row vector by matrix, giving vector result. Use this method to transform points from...
Definition SbLineard.h:741
SbMatrixd & multRight(const SbMatrixd &m)
Multiplies matrix by given matrix on right or left.
void multMatrixVec(const SbVec3d &src, SbVec3d &dst) const
Multiplies matrix by given column vector, giving vector result.
Oriented plane in 3D with double values.
Definition SbLineard.h:920
const SbVec3d & getNormal() const
Returns normal vector to plane.
Definition SbLineard.h:956
bool intersect(const SbLined &l, SbVec3d &intersection) const
Intersect line and plane, returning TRUE if there is an intersection, FALSE if line is parallel to pl...
SbPlaned()
Default constructor.
Definition SbLineard.h:923
void transform(const SbMatrixd &matrix)
Transforms the plane by the given matrix.
void offset(double d)
Offset a plane by a given distance.
SbPlaned(const SbVec3d &p0, const SbVec3d &p1, const SbVec3d &p2)
Construct a plane given three points.
SbPlaned(const SbVec3d &n, double d)
Construct a plane given normal and distance from origin along normal.
bool isInHalfSpace(const SbVec3d &point) const
Returns TRUE if the given point is within the half-space defined by the plane.
SbPlaned(const SbVec3d &n, const SbVec3d &p)
Construct a plane given normal and a point to pass through Orientation is given by the normal vector ...
double getDistanceFromOrigin() const
Returns distance from origin to plane.
Definition SbLineard.h:958
double getDistance(const SbVec3d &point) const
Returns the distance of the point to the plane.
Class for representing a rotation with double values.
Definition SbLineard.h:467
SbVec3d transformPoint(const SbVec3d &src) const
Multiplies the given vector by the matrix of this rotation.
Definition SbLineard.h:567
SbRotationd(const SbVec3d &axis, double radians)
Definition SbLineard.h:489
SbRotationd()
Default constructor, initialized to identity.
Definition SbLineard.h:471
bool equals(const SbRotationd &r, double tolerance) const
Equality comparison within given tolerance em the square of the length of the maximum distance betwee...
void multVec(const SbVec3d &src, SbVec3d &dst) const
Multiplies the given vector by the matrix of this rotation.
static SbRotationd slerp(const SbRotationd &rot0, const SbRotationd &rot1, double t)
Spherical linear interpolation: as t goes from 0 to 1, returned value goes from rot0 to rot1.
SbRotationd(double q0, double q1, double q2, double q3)
Definition SbLineard.h:481
SbRotationd & setValue(const SbVec3d &rotateFrom, const SbVec3d &rotateTo)
Sets rotation to rotate one direction vector to another.
SbRotationd(const SbVec3d &rotateFrom, const SbVec3d &rotateTo)
Constructors for rotation.
Definition SbLineard.h:501
void scaleAngle(double scaleFactor)
Keep the axis the same.
SbRotationd(const double v[4])
Definition SbLineard.h:477
SbRotationd & setValue(const SbVec3d &axis, double radians)
Sets value of vector from 3D rotation axis vector and angle in radians.
SbMatrixd getMatrix() const
Returns corresponding 4x4 rotation matrix.
SbRotationd & setValue(const SbMatrixd &m)
Sets value of rotation from a rotation matrix.
SbRotationd & setValue(double q0, double q1, double q2, double q3)
Sets value of rotation from 4 individual components of a quaternion.
SbRotationd(const SbMatrixd &m)
Definition SbLineard.h:485
void getValue(double &q0, double &q1, double &q2, double &q3) const
Returns 4 individual components of rotation quaternion.
static SbRotationd identity()
Returns a null rotation.
Definition SbLineard.h:579
SbVec3d getAxis() const
Returns corresponding 3D rotation axis vector.
Definition SbLineard.h:522
void getValue(SbMatrixd &matrix) const
Returns corresponding 4x4 rotation matrix.
void getValue(SbVec3d &axis, double &radians) const
Returns corresponding 3D rotation axis vector and angle in radians.
SbRotationd inverse() const
Returns the inverse of a rotation.
Definition SbLineard.h:530
double getAngle() const
Returns corresponding angle in radians.
Definition SbLineard.h:524
SbRotationd & invert()
Changes a rotation to be its inverse.
const double * getValue() const
Returns pointer to array of 4 components defining quaternion.
Definition SbLineard.h:505
SbRotationd & setValue(const double q[4])
Sets value of rotation from array of 4 components of a quaternion.
Class for representing a sphere with double values.
Definition SbLineard.h:1047
bool intersect(const SbLined &l, SbVec3d &enter, SbVec3d &exit) const
void circumscribe(const SbBox3d &box)
Return a sphere containing a given box.
void setValue(const SbVec3d &c, double r)
Change the center and radius.
void setRadius(double r)
Set just the center or radius.
SbSphered(const SbVec3d &c, double r)
Construct a sphere given center and radius.
const SbVec3d & getCenter() const
Return the center and radius.
Definition SbLineard.h:1065
SbSphered()
Constructors.
Definition SbLineard.h:1051
double getRadius() const
Return the center and radius.
Definition SbLineard.h:1067
bool intersect(const SbLined &l, SbVec3d &intersection) const
Intersect line and sphere, returning TRUE if there is an intersection.
void setCenter(const SbVec3d &c)
Set just the center or radius.
2D vector class with double members.
Definition SbLineard.h:242
double dot(const SbVec2d &v) const
Returns dot (inner) product of vector and another vector.
double length() const
Returns geometric length of vector.
SbVec2d & setValue(const double v[2])
Sets the vector components.
SbVec2d(double x, double y)
Constructor given vector components.
Definition SbLineard.h:252
double normalize()
Changes vector to be unit length.
void negate()
Negates each component of vector in place.
SbVec2d(const double v[2])
Constructor given vector components.
Definition SbLineard.h:249
bool equals(const SbVec2d v, double tolerance) const
Equality comparison within given tolerance em the square of the length of the maximum distance betwee...
const double * getValue() const
Returns vector components.
Definition SbLineard.h:258
SbVec2d()
Default constructor.
Definition SbLineard.h:246
SbVec2d & setValue(double x, double y)
Sets the vector components.
void getValue(double &x, double &y) const
Returns vector components.
3D vector class with double values.
Definition SbLineard.h:116
double dot(const SbVec3d &v) const
Returns dot (inner) product of vector and another vector.
SbVec3d & setValue(const double v[3])
Sets the vector components.
Definition SbLineard.h:155
SbVec3d(double x, double y, double z)
Constructor given vector components.
Definition SbLineard.h:127
double length() const
Returns geometric length of vector.
bool equals(const SbVec3d v, double tolerance) const
Equality comparison within given tolerance em the square of the length of the maximum distance betwee...
SbVec3d(const double v[3])
Constructor given vector components.
Definition SbLineard.h:123
SbVec3d cross(const SbVec3d &v) const
Returns right-handed cross product of vector and another vector.
SbVec3d getClosestAxis() const
Returns principal axis that is closest (based on maximum dot product) to this vector.
void negate()
Negates each component of vector in place.
void getValue(double &x, double &y, double &z) const
Returns vector components.
SbVec3d(SbPlaned &p0, SbPlaned &p1, SbPlaned &p2)
Constructor given 3 planes.
const double * getValue() const
Returns vector components.
Definition SbLineard.h:140
SbVec3d()
Default constructor.
Definition SbLineard.h:120
double normalize()
Changes vector to be unit length, returning the length before normalization.
SbVec3d & setValue(double x, double y, double z)
Sets the vector components.
Definition SbLineard.h:159
SbVec3d & setValue(const SbVec3d &barycentic, const SbVec3d &v0, const SbVec3d &v1, const SbVec3d &v2)
Sets value of vector to be convex combination of 3 other vectors, using barycentic coordinates.
4D vector class with double values.
Definition SbLineard.h:349
bool equals(const SbVec4d v, double tolerance) const
Equality comparison within given tolerance em the square of the length of the maximum distance betwee...
void getValue(double &x, double &y, double &z, double &w) const
Returns vector components.
SbVec4d(double x, double y, double z, double w)
Constructor given vector components.
Definition SbLineard.h:359
void getReal(SbVec3d &v) const
Returns the real portion of the vector by dividing by the fourth value.
SbVec4d & setValue(const double v[4])
Sets the vector components.
double length() const
Returns geometric length of vector.
SbVec4d(const double v[4])
Constructor given vector components.
Definition SbLineard.h:356
void negate()
Negates each component of vector in place.
double normalize()
Changes vector to be unit length.
double dot(const SbVec4d &v) const
Returns dot (inner) product of vector and another vector.
const double * getValue() const
Returns vector components.
Definition SbLineard.h:371
SbVec4d & setValue(double x, double y, double z, double w)
Sets the vector components.
SbVec3d getReal() const
Returns the real portion of the vector by dividing by the fourth value.
Definition SbLineard.h:368
SbVec4d()
Default constructor.
Definition SbLineard.h:353