Open Inventor Reference
SbLinear.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  | SbVec3f
52  | SbVec2f
53  | SbVec2s
54  | SbVec3s //!< Extension to SGI OIV 2.1
55  | SbVec4f
56  | SbRotation
57  | SbMatrix
58  | SbViewVolume
59  |
60  | SbLine
61  | SbPlane
62  | SbSphere
63  |
64  | Author(s) : Paul S. Strauss, Nick Thompson,
65  | David Mott, Alain Dumesny
66  |
67  ______________ S I L I C O N G R A P H I C S I N C . ____________
68  _______________________________________________________________________
69  */
70 
71 #ifndef _SB_LINEAR_
72 #define _SB_LINEAR_
73 
75 #include <math.h>
76 #include <Inventor/SbBasic.h>
77 
83 
84 typedef float SbMat[4][4];
85 
86 
87 class SbVec3f;
88 class SbVec2f;
89 class SbVec2s;
90 class SbVec4f;
91 class SbRotation;
92 class SbMatrix;
93 
94 class SbLine;
95 class SbPlane;
96 class SbCylinder;
97 class SbSphere;
98 
100 class SbBox3f;
101 
102 
103 
104 
107 
119 
121  public:
122 
124  SbVec3f() { vec[0] = 0.f; vec[1] = 0.f; vec[2] = 0.f; }
125 
127  SbVec3f(const float v[3])
128  { vec[0] = v[0]; vec[1] = v[1]; vec[2] = v[2]; }
129 
131  SbVec3f(float x, float y, float z)
132  { vec[0] = x; vec[1] = y; vec[2] = z; }
133 
135  SbVec3f(SbPlane &p0, SbPlane &p1, SbPlane &p2);
136 
138  SbVec3f cross(const SbVec3f &v) const;
139 
141  float dot(const SbVec3f &v) const;
142 
144  const float *getValue() const { return vec; }
145 
147  void getValue(float &x, float &y, float &z) const;
148 
150  float length() const;
151 
153  float normalize();
154 
156  void negate();
157 
159  SbVec3f & setValue(const float v[3])
160  { vec[0] = v[0]; vec[1] = v[1]; vec[2] = v[2]; return *this; }
161 
163  SbVec3f & setValue(float x, float y, float z)
164  { vec[0] = x; vec[1] = y; vec[2] = z; return *this; }
165 
168  SbVec3f & setValue(const SbVec3f &barycentic,
169  const SbVec3f &v0, const SbVec3f &v1, const SbVec3f &v2);
170 
172  float & operator [](int i) { return (vec[i]); }
173  const float & operator [](int i) const { return (vec[i]); }
174 
176  SbVec3f & operator *=(float d);
177 
179  SbVec3f & operator /=(float d)
180  { return *this *= (1.0f / d); }
181 
183  SbVec3f & operator +=(SbVec3f v);
185  SbVec3f & operator -=(SbVec3f v);
186 
189 
191  friend INVENTOR_API SbVec3f operator *(const SbVec3f &v, float d);
192  friend INVENTOR_API SbVec3f operator *(float d, const SbVec3f &v);
193  friend INVENTOR_API SbVec3f operator /(const SbVec3f &v, float d);
194 
196  friend INVENTOR_API SbVec3f operator +(const SbVec3f &v1, const SbVec3f &v2);
197 
198  friend INVENTOR_API SbVec3f operator -(const SbVec3f &v1, const SbVec3f &v2);
199 
201  friend INVENTOR_API bool operator ==(const SbVec3f &v1, const SbVec3f &v2);
202  friend INVENTOR_API bool operator !=(const SbVec3f &v1, const SbVec3f &v2);
203 
206  bool equals(const SbVec3f v, float tolerance) const;
207 
211 
212  protected:
213  float vec[3];
214 };
215 
217 inline INVENTOR_API SbVec3f operator *(float d, const SbVec3f &v)
218 { return v * d; }
219 inline INVENTOR_API SbVec3f operator /(const SbVec3f &v, float d)
220 { return v * (1.0f / d); }
221 
224 INVENTOR_API bool operator ==(const SbVec3f &v1, const SbVec3f &v2);
225 inline INVENTOR_API bool operator !=(const SbVec3f &v1, const SbVec3f &v2)
226 { return !(v1 == v2); }
227 
228 
229 
230 
233 
245 
247  public:
248 
250  SbVec2f() { vec[0] = 0.f; vec[1] = 0.f; }
251 
253  SbVec2f(const float v[2]) { setValue(v); }
254 
256  SbVec2f(float x, float y) { setValue(x, y); }
257 
259  float dot(const SbVec2f &v) const;
260 
262  const float *getValue() const { return vec; }
263 
265  void getValue(float &x, float &y) const;
266 
268  float length() const;
269 
271  void negate();
272 
274  float normalize();
275 
277  SbVec2f & setValue(const float v[2]);
278 
280  SbVec2f & setValue(float x, float y);
281 
283  float & operator [](int i) { return (vec[i]); }
284  const float & operator [](int i) const { return (vec[i]); }
285 
287  SbVec2f & operator *=(float d);
288 
290  SbVec2f & operator /=(float d)
291  { return *this *= (1.0f / d); }
292 
294  SbVec2f & operator +=(const SbVec2f &u);
296  SbVec2f & operator -=(const SbVec2f &u);
297 
300 
302  friend INVENTOR_API SbVec2f operator *(const SbVec2f &v, float d);
303  friend INVENTOR_API SbVec2f operator *(float d, const SbVec2f &v);
304  friend INVENTOR_API SbVec2f operator /(const SbVec2f &v, float d);
305 
307  friend INVENTOR_API SbVec2f operator +(const SbVec2f &v1, const SbVec2f &v2);
308 
309  friend INVENTOR_API SbVec2f operator -(const SbVec2f &v1, const SbVec2f &v2);
310 
312  friend INVENTOR_API bool operator ==(const SbVec2f &v1, const SbVec2f &v2);
313  friend INVENTOR_API bool operator !=(const SbVec2f &v1, const SbVec2f &v2);
314 
317  bool equals(const SbVec2f v, float tolerance) const;
318 
319  protected:
320  float vec[2];
321 };
322 
324 inline INVENTOR_API SbVec2f operator *(float d, const SbVec2f &v)
325 { return v * d; }
326 inline INVENTOR_API SbVec2f operator /(const SbVec2f &v, float d)
327 { return v * (1.0f / d); }
328 
330 
332 
333 INVENTOR_API bool operator ==(const SbVec2f &v1, const SbVec2f &v2);
334 inline INVENTOR_API bool operator !=(const SbVec2f &v1, const SbVec2f &v2)
335 { return !(v1 == v2); }
336 
337 
338 
341 
353 
355  public:
356 
358  SbVec2s() { vec[0] = 0; vec[1] = 0; }
359 
361  SbVec2s(const short v[2]) { setValue(v); }
362 
364  SbVec2s(short x, short y) { setValue(x, y); }
365 
367  int32_t dot(const SbVec2s &v) const;
368 
370  const short *getValue() const { return vec; }
371 
373  void getValue(short &x, short &y) const;
374 
376  void negate();
377 
379  SbVec2s & setValue(const short v[2]);
380 
382  SbVec2s & setValue(short x, short y);
383 
385  short & operator [](int i) { return (vec[i]); }
386  const short & operator [](int i) const { return (vec[i]); }
387 
389  SbVec2s & operator *=(int d);
391  SbVec2s & operator *=(double d);
392 
394  SbVec2s & operator /=(int d);
396  SbVec2s & operator /=(double d)
397  { return *this *= (1.0 / d); }
398 
400  SbVec2s & operator +=(const SbVec2s &u);
402  SbVec2s & operator -=(const SbVec2s &u);
403 
406 
408  friend INVENTOR_API SbVec2s operator *(const SbVec2s &v, int d);
409  friend INVENTOR_API SbVec2s operator *(const SbVec2s &v, double d);
410  friend INVENTOR_API SbVec2s operator *(int d, const SbVec2s &v);
411  friend INVENTOR_API SbVec2s operator *(double d, const SbVec2s &v);
412  friend INVENTOR_API SbVec2s operator /(const SbVec2s &v, int d);
413  friend INVENTOR_API SbVec2s operator /(const SbVec2s &v, double d);
414 
416  friend INVENTOR_API SbVec2s operator +(const SbVec2s &v1, const SbVec2s &v2);
417 
418  friend INVENTOR_API SbVec2s operator -(const SbVec2s &v1, const SbVec2s &v2);
419 
421  friend INVENTOR_API bool operator ==(const SbVec2s &v1, const SbVec2s &v2);
422  friend INVENTOR_API bool operator !=(const SbVec2s &v1, const SbVec2s &v2);
423 
424  protected:
425  short vec[2];
426 };
427 
430 inline INVENTOR_API SbVec2s operator *(int d, const SbVec2s &v)
431 { return v * d; }
432 inline INVENTOR_API SbVec2s operator *(double d, const SbVec2s &v)
433 { return v * d; }
435 inline INVENTOR_API SbVec2s operator /(const SbVec2s &v, double d)
436 { return v * (1.0 / d); }
437 
440 
441 INVENTOR_API bool operator ==(const SbVec2s &v1, const SbVec2s &v2);
442 inline INVENTOR_API bool operator !=(const SbVec2s &v1, const SbVec2s &v2)
443 { return !(v1 == v2); }
444 
453 
455  public:
456 
458  SbVec3s() { vec[0] = 0; vec[1] = 0; vec[2] = 0; }
459 
461  SbVec3s(const short v[3]) { setValue(v); }
462 
464  SbVec3s(short x, short y, short z) { setValue(x, y, z); }
465 
467  int32_t dot(const SbVec3s &v) const;
468 
470  const short *getValue() const { return vec; }
471 
473  void getValue(short &x, short &y, short &z) const;
474 
476  void negate();
477 
479  SbVec3s & setValue(const short v[3]);
480 
482  SbVec3s & setValue(short x, short y, short z);
483 
485  short & operator [](int i) { return (vec[i]); }
486  const short & operator [](int i) const { return (vec[i]); }
487 
489  SbVec3s & operator *=(int d);
490  SbVec3s & operator *=(double d);
491 
492  SbVec3s & operator /=(int d);
493  SbVec3s & operator /=(double d)
494  { return *this *= (1.0 / d); }
495 
497  SbVec3s & operator +=(const SbVec3s &u);
499  SbVec3s & operator -=(const SbVec3s &u);
500 
503 
505  friend INVENTOR_API SbVec3s operator *(const SbVec3s &v, int d);
506  friend INVENTOR_API SbVec3s operator *(const SbVec3s &v, double d);
507  friend INVENTOR_API SbVec3s operator *(int d, const SbVec3s &v);
508  friend INVENTOR_API SbVec3s operator *(double d, const SbVec3s &v);
509  friend INVENTOR_API SbVec3s operator /(const SbVec3s &v, int d);
510  friend INVENTOR_API SbVec3s operator /(const SbVec3s &v, double d);
511 
513  friend INVENTOR_API SbVec3s operator +(const SbVec3s &v1, const SbVec3s &v2);
514 
515  friend INVENTOR_API SbVec3s operator -(const SbVec3s &v1, const SbVec3s &v2);
516 
518  friend INVENTOR_API bool operator ==(const SbVec3s &v1, const SbVec3s &v2);
519  friend INVENTOR_API bool operator !=(const SbVec3s &v1, const SbVec3s &v2);
520 
521  protected:
522  short vec[3];
523 };
524 
525 
528 inline INVENTOR_API SbVec3s operator *(int d, const SbVec3s &v)
529 { return v * d; }
530 inline INVENTOR_API SbVec3s operator *(double d, const SbVec3s &v)
531 { return v * d; }
533 inline INVENTOR_API SbVec3s operator /(const SbVec3s &v, double d)
534 { return v * (1.0 / d); }
535 
538 
539 INVENTOR_API bool operator ==(const SbVec3s &v1, const SbVec3s &v2);
540 inline INVENTOR_API bool operator !=(const SbVec3s &v1, const SbVec3s &v2)
541 { return !(v1 == v2); }
542 
543 
546 
558 
560  public:
561 
563  SbVec4f() { vec[0] = 0.f; vec[1] = 0.f; vec[2] = 0.f; vec[3] = 0.f; }
564 
566  SbVec4f(const float v[4]) { setValue(v); }
567 
569  SbVec4f(float x, float y, float z, float w) { setValue(x, y, z, w); }
570 
572  float dot(const SbVec4f &v) const;
573 
575  void getReal(SbVec3f &v) const;
576 
578  SbVec3f getReal() const { SbVec3f tmp; getReal(tmp); return tmp; }
579 
581  const float *getValue() const { return vec; }
582 
584  void getValue(float &x, float &y, float &z, float &w) const;
585 
587  float length() const;
588 
590  void negate();
591 
593  float normalize();
594 
596  SbVec4f & setValue(const float v[4]);
597 
599  SbVec4f & setValue(float x, float y, float z, float w);
600 
602  float & operator [](int i) { return (vec[i]); }
603  const float & operator [](int i) const { return (vec[i]); }
604 
606  SbVec4f & operator *=(float d);
607 
609  SbVec4f & operator /=(float d)
610  { return *this *= (1.0f / d); }
611 
613  SbVec4f & operator +=(const SbVec4f &u);
615  SbVec4f & operator -=(const SbVec4f &u);
616 
619 
621  friend INVENTOR_API SbVec4f operator *(const SbVec4f &v, float d);
622  friend INVENTOR_API SbVec4f operator *(float d, const SbVec4f &v);
623  friend INVENTOR_API SbVec4f operator /(const SbVec4f &v, float d);
624 
626  friend INVENTOR_API SbVec4f operator +(const SbVec4f &v1, const SbVec4f &v2);
627 
628  friend INVENTOR_API SbVec4f operator -(const SbVec4f &v1, const SbVec4f &v2);
629 
631  friend INVENTOR_API bool operator ==(const SbVec4f &v1, const SbVec4f &v2);
632  friend INVENTOR_API bool operator !=(const SbVec4f &v1, const SbVec4f &v2);
633 
636  bool equals(const SbVec4f v, float tolerance) const;
637 
638  protected:
639  float vec[4];
640 };
641 
643 inline INVENTOR_API SbVec4f operator *(float d, const SbVec4f &v)
644 { return v * d; }
645 inline INVENTOR_API SbVec4f operator /(const SbVec4f &v, float d)
646 { return v * (1.0f / d); }
647 
649 
651 
652 INVENTOR_API bool operator ==(const SbVec4f &v1, const SbVec4f &v2);
653 inline INVENTOR_API bool operator !=(const SbVec4f &v1, const SbVec4f &v2)
654 { return !(v1 == v2); }
655 
656 
657 
660 
677 
679  public:
680 
683  { quat[0] = 0.f; quat[1] = 0.f; quat[2] = 0.f; quat[3] = 1.f; }
684 
686  SbRotation(const float v[4])
687  { setValue(v); }
688 
690  SbRotation(float q0, float q1, float q2, float q3)
691  { setValue(q0, q1, q2, q3); }
692 
695  { setValue(m); }
696 
698  SbRotation(const SbVec3f &axis, float radians)
699  { setValue(axis, radians); }
700 
710  SbRotation(const SbVec3f &rotateFrom, const SbVec3f &rotateTo)
711  { setValue(rotateFrom, rotateTo); }
712 
714  const float * getValue() const
715  { return (quat); }
716 
718  void getValue(float &q0, float &q1,
719  float &q2, float &q3) const;
720 
722  void getValue(SbVec3f &axis, float &radians) const;
723 
725  void getValue(SbMatrix &matrix) const;
726 
729 
731  SbVec3f getAxis() const { SbVec3f axis; float radians; getValue(axis, radians); return axis; }
733  float getAngle() const { SbVec3f axis; float radians; getValue(axis, radians); return radians; }
734 
737 
740  { SbRotation q = *this; return q.invert(); }
741 
743  SbRotation & setValue(const float q[4]);
744 
746  SbRotation & setValue(float q0, float q1, float q2, float q3);
747 
750 
752  SbRotation & setValue(const SbVec3f &axis, float radians);
753 
755  SbRotation & setValue(const SbVec3f &rotateFrom,
756  const SbVec3f &rotateTo);
757 
759  SbRotation & operator *=(const SbRotation &q);
760 
762  friend INVENTOR_API bool operator ==(const SbRotation &q1, const SbRotation &q2);
763  friend INVENTOR_API bool operator !=(const SbRotation &q1, const SbRotation &q2);
764 
767  bool equals(const SbRotation &r, float tolerance) const;
768 
771 
773  void multVec(const SbVec3f &src, SbVec3f &dst) const;
774 
776  SbVec3f transformPoint(const SbVec3f &src) const { SbVec3f dst; multVec(src, dst); return dst; }
777 
780  void scaleAngle( float scaleFactor );
781 
784  static SbRotation slerp(const SbRotation &rot0,
785  const SbRotation &rot1, float t);
786 
789  { return SbRotation(0.0, 0.0, 0.0, 1.0); }
790 
791  private:
792  float quat[4];
793 
795  float norm() const;
796 
798  void normalize();
799 };
800 
801 INVENTOR_API bool operator ==(const SbRotation &q1, const SbRotation &q2);
802 inline INVENTOR_API bool operator !=(const SbRotation &q1, const SbRotation &q2)
803 { return !(q1 == q2); }
805 
806 
807 
810 
822 
824  public:
825 
828  makeIdentity();
829  }
830 
832  SbMatrix(float a11, float a12, float a13, float a14,
833  float a21, float a22, float a23, float a24,
834  float a31, float a32, float a33, float a34,
835  float a41, float a42, float a43, float a44);
836 
838  SbMatrix(const SbMat &m);
839 
841  void setValue(const SbMat &m);
842 
844  void setValue(const float* data);
845 
846  public:
847 
849  void makeIdentity();
850 
852  static SbMatrix identity();
853 
855  void setRotate(const SbRotation &q);
856 
858  void setScale(float s);
859 
861  void setScale(const SbVec3f &s);
862 
864  void setTranslate(const SbVec3f &t);
865 
871  const SbVec3f &translation,
872  const SbRotation &rotation,
873  const SbVec3f &scaleFactor,
874  const SbRotation &scaleOrientation,
875  const SbVec3f &center);
878  void setTransform(const SbVec3f &t, const SbRotation &r,
879  const SbVec3f &s)
880  { setTransform(t, r, s,
881  SbRotation(0,0,0,1), SbVec3f(0,0,0)); }
882  void setTransform(const SbVec3f &t, const SbRotation &r,
883  const SbVec3f &s, const SbRotation &so)
884  { setTransform(t, r, s, so, SbVec3f(0,0,0)); }
885 
893  void getTransform(SbVec3f &translation,
894  SbRotation &rotation,
895  SbVec3f &scaleFactor,
896  SbRotation &scaleOrientation,
897  const SbVec3f &center) const;
899  SbVec3f &s, SbRotation &so) const
900  { getTransform(t, r, s, so, SbVec3f(0,0,0)); }
901 
902 
904 
906  void getValue(SbMat &m) const;
907  const SbMat & getValue() const { return matrix; }
908 
911  float det3(int r1, int r2, int r3, int c1, int c2, int c3) const;
912 
914  float det3() const { return det3(0, 1, 2, 0, 1, 2); }
915 
917  float det4() const;
918 
924  bool factor(SbMatrix &r, SbVec3f &s, SbMatrix &u,
925  SbVec3f &t, SbMatrix &proj) const;
926 
929  SbMatrix inverse() const;
930 
933  bool LUDecomposition(int index[4], float &d);
934 
937  void LUBackSubstitution(int index[4], float b[4]) const;
938 
941 
943  SbMatrix & multRight(const SbMatrix &m); // this = this * m
945  SbMatrix & multLeft(const SbMatrix &m); // this = m * this
946 
948  SbVec3f transformPoint(const SbVec3f &src) const { SbVec3f dst; multVecMatrix(src, dst); return dst; }
950  SbVec4f transformPoint(const SbVec4f &src) const { SbVec4f dst; multVecMatrix(src, dst); return dst; }
951 
960  SbVec3f transformDirection(const SbVec3f &src) const { SbVec3f dst; multDirMatrix(src, dst); return dst; }
961 
964  SbLine transformLine(const SbLine &src) const;
965 
968  void multMatrixVec(const SbVec3f &src, SbVec3f &dst) const;
969 
971  void multVecMatrix(const SbVec3f &src, SbVec3f &dst) const;
973  void multVecMatrix(const SbVec4f &src, SbVec4f &dst) const;
975  void multVecMatrix(const SbVec3f &src, SbVec4f &dst) const;
976 
985  void multDirMatrix(const SbVec3f &src, SbVec3f &dst) const;
986 
989  void multLineMatrix(const SbLine &src, SbLine &dst) const;
990 
992  void print(FILE *fp) const;
993 
995  operator float *() { return &matrix[0][0]; }
996 
998  operator SbMat &() { return matrix; }
999 
1001  float * operator [](int i) { return &matrix[i][0]; }
1002  const float * operator [](int i) const { return &matrix[i][0]; }
1003 
1005  SbMatrix & operator =(const SbMat &m);
1006 
1008  SbMatrix & operator =(const SbMatrix &m);
1009 
1011  SbMatrix & operator =(const SbRotation &q) { setRotate(q); return *this; }
1012 
1014  SbMatrix & operator *=(const SbMatrix &m) { return multRight(m); }
1015 
1017  friend INVENTOR_API SbMatrix operator *(const SbMatrix &m1, const SbMatrix &m2);
1018 
1020  friend INVENTOR_API bool operator ==(const SbMatrix &m1, const SbMatrix &m2);
1021  friend INVENTOR_API bool operator !=(const SbMatrix &m1, const SbMatrix &m2);
1022 
1024  bool equals(const SbMatrix &m, float tolerance) const;
1025 
1026  private:
1027  SbMat matrix;
1028 
1030  void jacobi3(float evalues[3], SbVec3f evectors[3], int &rots) const;
1031 
1032  bool affine_inverse(const SbMatrix &in, SbMatrix &out) const;
1033 };
1034 
1036 
1037 INVENTOR_API bool operator ==(const SbMatrix &m1, const SbMatrix &m2);
1038 inline INVENTOR_API bool operator !=(const SbMatrix &m1, const SbMatrix &m2)
1039 { return !(m1 == m2); }
1040 
1041 
1044 
1057 
1059  public:
1060 
1065 
1070  void getMatrices(SbMatrix &affine, SbMatrix &proj) const;
1071 
1073  SbMatrix getViewingMatrix() const { SbMatrix affine; SbMatrix proj; getMatrices(affine, proj); return affine; }
1074 
1076  SbMatrix getProjectionMatrix() const { SbMatrix affine; SbMatrix proj; getMatrices(affine, proj); return proj; }
1077 
1081 
1087 
1089  void projectPointToLine(const SbVec2f &pt,
1090  SbLine &line) const;
1091  void projectPointToLine(const SbVec2f &pt,
1092  SbVec3f &line0, SbVec3f &line1) const;
1095 
1101  void projectToScreen(const SbVec3f &src,
1102  SbVec3f &dst) const;
1103 
1109  SbVec3f projectToScreen(const SbVec3f &src) const { SbVec3f dst; projectToScreen(src, dst); return dst; }
1110 
1113  SbPlane getPlane(float distFromEye) const;
1114 
1117  SbVec3f getSightPoint(float distFromEye) const;
1118 
1122  SbVec3f getPlanePoint(float distFromEye,
1123  const SbVec2f &normPoint) const;
1124 
1130  SbRotation getAlignRotation(bool rightAngleOnly = FALSE) const;
1131 
1135  float getWorldToScreenScale(const SbVec3f &worldCenter,
1136  float normRadius) const;
1137 
1141  SbVec2f projectBox(const SbBox3f &box) const;
1142 
1147  SbViewVolume narrow(float left, float bottom,
1148  float right, float top) const;
1149 
1153  SbViewVolume narrow(const SbBox3f &box) const;
1154 
1157  void ortho(float left, float right,
1158  float bottom, float top,
1159  float nearVal, float farVal);
1160 
1165  void perspective(float fovy, float aspect,
1166  float nearVal, float farVal);
1167 
1171  void rotateCamera(const SbRotation &q);
1172 
1176  void translateCamera(const SbVec3f &v);
1177 
1181  SbVec3f zVector() const;
1182 
1188  SbViewVolume zNarrow(float nearVal, float farVal) const;
1189 
1191  void scale(float factor);
1192 
1196  void scaleWidth(float ratio);
1200  void scaleHeight(float ratio);
1201 
1205  PERSPECTIVE
1206  };
1207 
1209  ProjectionType getProjectionType() const { return type; }
1210 
1212  const SbVec3f & getProjectionPoint() const { return projPoint; }
1213 
1215  const SbVec3f & getProjectionDirection() const { return projDir; }
1216 
1218  float getNearDist() const { return nearDist; }
1219 
1221  float getFarDist() const { return nearDist + nearToFar; }
1222 
1224  float getWidth() const { return (lrfO-llfO).length(); }
1226  float getHeight() const { return (ulfO-llfO).length(); }
1228  float getDepth() const { return nearToFar; }
1229 
1230  SoINTERNAL public:
1232 
1237  float nearDist;
1238  float nearToFar;
1242 
1247  void transform(const SbMatrix &matrix);
1248 
1250  bool intersect(const SbVec3f &point) const;
1251 
1255  bool intersect(const SbVec3f &p0, const SbVec3f &p1,
1256  SbVec3f &closestPoint) const;
1257 
1259  bool intersect(const SbBox3f &box) const;
1260 
1263  bool outsideTest(const SbPlane &p,
1264  const SbVec3f &min, const SbVec3f &max) const;
1265 
1266  private:
1269  SbVec3f llfO;
1270  SbVec3f lrfO;
1271  SbVec3f ulfO;
1272 };
1273 
1274 
1275 
1278 
1291 
1293  public:
1296  SbLine() {}
1297 
1300  SbLine(const SbVec3f &p0, const SbVec3f &p1);
1301 
1303  void setValue(const SbVec3f &p0, const SbVec3f &p1);
1304 
1309  bool getClosestPoints(const SbLine &line2,
1310  SbVec3f &ptOnThis,
1311  SbVec3f &ptOnLine2 ) const;
1312 
1314  SbVec3f getClosestPoint(const SbVec3f &point) const;
1315 
1317  const SbVec3f & getPosition() const { return pos; }
1319  const SbVec3f & getDirection() const { return dir; }
1320 
1321 
1322  SoINTERNAL public:
1324  bool intersect( const SbBox3f &box,
1325  SbVec3f &enter, SbVec3f &exit ) const;
1326  bool intersect( float angle, const SbBox3f &box ) const;
1327  bool intersect( float angle, const SbVec3f &point ) const;
1328  bool intersect( float angle, const SbVec3f &v0,
1329  const SbVec3f &v1, SbVec3f &pt ) const;
1330  bool intersect( const SbVec3f &v0,
1331  const SbVec3f &v1,
1332  const SbVec3f &v2,
1333  SbVec3f &pt, SbVec3f &barycentric,
1334  bool &front ) const;
1335 
1336  private:
1339  SbVec3f pos;
1340  SbVec3f dir;
1341 };
1342 
1343 
1344 
1347 
1359 
1361  public:
1363  SbPlane() { distance = 0.f; }
1364 
1367  SbPlane(const SbVec3f &p0, const SbVec3f &p1, const SbVec3f &p2);
1368 
1371  SbPlane(const SbVec3f &n, float d);
1372 
1375  SbPlane(const SbVec3f &n, const SbVec3f &p);
1376 
1378  void offset(float d);
1379 
1382  bool intersect(const SbLine &l,
1383  SbVec3f &intersection) const;
1384 
1386  void transform(const SbMatrix &matrix);
1387 
1390  bool isInHalfSpace(const SbVec3f &point) const;
1391 
1393  float getDistance(const SbVec3f &point) const;
1394 
1396  const SbVec3f & getNormal() const { return normalVec; }
1398  float getDistanceFromOrigin() const { return distance; }
1399 
1401  friend INVENTOR_API bool operator ==(const SbPlane &p1, const SbPlane &p2);
1402  friend INVENTOR_API bool operator !=(const SbPlane &p1, const SbPlane &p2);
1403 
1404  private:
1406 
1408  SbVec3f normalVec;
1409 
1411  float distance;
1412 };
1413 
1415 INVENTOR_API bool operator ==(const SbPlane &p1, const SbPlane &p2);
1416 inline INVENTOR_API bool operator !=(const SbPlane &p1, const SbPlane &p2)
1417 { return !(p1 == p2); }
1418 
1419 
1422 
1434 
1436  public:
1437 
1440 
1442  SbCylinder(const SbLine &a, float r);
1443 
1445  void setValue(const SbLine &a, float r);
1446 
1448  void setAxis(const SbLine &a);
1450  void setRadius(float r);
1451 
1453  const SbLine & getAxis() const { return axis; }
1455  float getRadius() const { return radius; }
1456 
1458  bool intersect(const SbLine &l, SbVec3f &intersection) const;
1459  bool intersect(const SbLine &l,
1460  SbVec3f &enter, SbVec3f &exit) const;
1461 
1462  private:
1463  SbLine axis;
1464  float radius;
1465 
1466  static bool unitCylinderIntersect(const SbLine &l,
1467  SbVec3f &in, SbVec3f &out);
1468 };
1469 
1470 
1471 
1472 
1475 
1488 
1490  public:
1491 
1493  SbSphere() { radius = 0.f; }
1494 
1496  SbSphere(const SbVec3f &c, float r);
1497 
1499  void setValue(const SbVec3f &c, float r);
1500 
1502  void setCenter(const SbVec3f &c);
1504  void setRadius(float r);
1505 
1507  const SbVec3f & getCenter() const { return center; }
1509  float getRadius() const { return radius; }
1510 
1512  void circumscribe(const SbBox3f &box);
1513 
1515  bool intersect(const SbLine &l, SbVec3f &intersection) const;
1516  bool intersect(const SbLine &l, SbVec3f &enter, SbVec3f &exit) const;
1517 
1518  private:
1519  SbVec3f center;
1520  float radius;
1521 };
1522 
1523 #endif /* _SB_LINEAR_ */
#define FALSE
Definition: SbBasic.h:79
#define SoINTERNAL
Definition: SbBasic.h:155
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 bool operator==(const SbVec3f &v1, const SbVec3f &v2)
INVENTOR_API SbVec3f operator*(const SbVec3f &v, float d)
float SbMat[4][4]
Definition: SbLinear.h:84
INVENTOR_API bool operator!=(const SbVec3f &v1, const SbVec3f &v2)
Definition: SbLinear.h:225
INVENTOR_API SbVec3f operator+(const SbVec3f &v1, const SbVec3f &v2)
#define INVENTOR_API
Disable some annoying warnings on MSVC 6.
Definition: SbSystem.h:81
signed int int32_t
Definition: SbTypeDefs.h:43
3D box class.
Definition: SbBox.h:81
Class for representing a cylinder.
Definition: SbLinear.h:1435
const SbLine & getAxis() const
Return the axis and radius.
Definition: SbLinear.h:1453
SbCylinder(const SbLine &a, float r)
Create cylinder from axis and radius.
bool intersect(const SbLine &l, SbVec3f &intersection) const
Intersect line and cylinder, returning TRUE if there is an intersection.
void setAxis(const SbLine &a)
Set just the axis or radius.
void setRadius(float r)
Set just the axis or radius.
void setValue(const SbLine &a, float r)
Change the axis and radius.
SbCylinder()
Default Constructor.
float getRadius() const
Return the axis and radius.
Definition: SbLinear.h:1455
bool intersect(const SbLine &l, SbVec3f &enter, SbVec3f &exit) const
Directed line in 3D.
Definition: SbLinear.h:1292
bool intersect(float angle, const SbVec3f &v0, const SbVec3f &v1, SbVec3f &pt) const
bool intersect(float angle, const SbVec3f &point) const
const SbVec3f & getPosition() const
Returns position of line origin point and direction vector of line.
Definition: SbLinear.h:1317
bool intersect(const SbVec3f &v0, const SbVec3f &v1, const SbVec3f &v2, SbVec3f &pt, SbVec3f &barycentric, bool &front) const
SbLine()
Constructors.
Definition: SbLinear.h:1296
bool intersect(float angle, const SbBox3f &box) const
bool intersect(const SbBox3f &box, SbVec3f &enter, SbVec3f &exit) const
Intersect the line with a box, point, line, and triangle.
SbVec3f getClosestPoint(const SbVec3f &point) const
Returns the closest point on the line to the given point.
void setValue(const SbVec3f &p0, const SbVec3f &p1)
Sets line to pass through points p0 and p1.
bool getClosestPoints(const SbLine &line2, SbVec3f &ptOnThis, SbVec3f &ptOnLine2) const
Finds the two closest points between this line and line2, and loads them into ptOnThis and ptOnLine2.
SbLine(const SbVec3f &p0, const SbVec3f &p1)
Constructors.
const SbVec3f & getDirection() const
Returns position of line origin point and direction vector of line.
Definition: SbLinear.h:1319
4x4 matrix class.
Definition: SbLinear.h:823
bool factor(SbMatrix &r, SbVec3f &s, SbMatrix &u, SbVec3f &t, SbMatrix &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...
SbMatrix(float a11, float a12, float a13, float a14, float a21, float a22, float a23, float a24, float a31, float a32, float a33, float a34, float a41, float a42, float a43, float a44)
Constructor given all 16 elements in row-major order.
void LUBackSubstitution(int index[4], float b[4]) const
Perform back-substitution on LU-decomposed matrix.
void multVecMatrix(const SbVec4f &src, SbVec4f &dst) const
Multiplies given row vector by matrix, giving vector result. Takes homogenous coordinate and returns ...
void setScale(const SbVec3f &s)
Sets matrix to scale by given vector.
void multLineMatrix(const SbLine &src, SbLine &dst) const
Multiplies the given line's origin by the matrix, and the line's direction by the rotation portion of...
void multVecMatrix(const SbVec3f &src, SbVec4f &dst) const
Multiplies given row vector by matrix, giving vector result. Takes SbVec4(src,1.f) coordinate and ret...
void setTransform(const SbVec3f &t, const SbRotation &r, const SbVec3f &s, const SbRotation &so)
Definition: SbLinear.h:882
float det4() const
Returns determinant of entire matrix.
float det3() const
Returns determinant of upper-left 3x3 submatrix.
Definition: SbLinear.h:914
SbMatrix()
Default constructor, initialized to identity.
Definition: SbLinear.h:827
void getTransform(SbVec3f &translation, SbRotation &rotation, SbVec3f &scaleFactor, SbRotation &scaleOrientation, const SbVec3f &center) const
Decomposes the matrix into a translation, rotation, scale, and scale orientation.
void getTransform(SbVec3f &t, SbRotation &r, SbVec3f &s, SbRotation &so) const
Definition: SbLinear.h:898
void setValue(const float *data)
Sets value from a float array of 16 elements.
void print(FILE *fp) const
Prints a formatted version of the matrix to the given file pointer.
bool LUDecomposition(int index[4], float &d)
Perform in-place LU decomposition of matrix.
SbMatrix & multRight(const SbMatrix &m)
Multiplies matrix by given matrix on right or left.
const SbMat & getValue() const
Definition: SbLinear.h:907
static SbMatrix identity()
Returns an identity matrix.
void setValue(const SbMat &m)
Sets value from 4x4 array of elements.
void setScale(float s)
Sets matrix to scale by given uniform factor.
void multDirMatrix(const SbVec3f &src, SbVec3f &dst) const
Multiplies given row vector by matrix, giving vector result.
SbVec4f transformPoint(const SbVec4f &src) const
Multiplies given row vector by matrix, giving vector result. Takes homogenous coordinate and returns ...
Definition: SbLinear.h:950
void setTranslate(const SbVec3f &t)
Sets matrix to translate by given vector.
SbVec3f transformDirection(const SbVec3f &src) const
Multiplies given row vector by matrix, giving vector result.
Definition: SbLinear.h:960
void setTransform(const SbVec3f &translation, const SbRotation &rotation, const SbVec3f &scaleFactor, const SbRotation &scaleOrientation, const SbVec3f &center)
Composes the matrix based on a translation, rotation, scale, orientation for scale,...
float 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).
bool equals(const SbMatrix &m, float tolerance) const
Equality comparison within given tolerance, for each component.
void makeIdentity()
Sets matrix to be identity.
void setTransform(const SbVec3f &t, const SbRotation &r, const SbVec3f &s)
Overloaded methods as a kludge because the compiler won't let us have SbVec3f(0,0,...
Definition: SbLinear.h:878
SbLine transformLine(const SbLine &src) const
Multiplies the given line's origin by the matrix, and the line's direction by the rotation portion of...
SbMatrix transpose() const
Returns transpose of matrix.
void multVecMatrix(const SbVec3f &src, SbVec3f &dst) const
Multiplies given row vector by matrix, giving vector result. Use this method to transform points from...
SbMatrix & multLeft(const SbMatrix &m)
Multiplies matrix by given matrix on right or left.
void setRotate(const SbRotation &q)
Sets matrix to rotate by given rotation.
SbMatrix(const SbMat &m)
Constructors.
void multMatrixVec(const SbVec3f &src, SbVec3f &dst) const
Multiplies matrix by given column vector, giving vector result.
SbMatrix inverse() const
Returns inverse of matrix.
SbVec3f transformPoint(const SbVec3f &src) const
Multiplies given row vector by matrix, giving vector result. Use this method to transform points from...
Definition: SbLinear.h:948
void getValue(SbMat &m) const
The following methods return matrix values and other info:
Oriented plane in 3D.
Definition: SbLinear.h:1360
SbPlane(const SbVec3f &n, float d)
Construct a plane given normal and distance from origin along normal.
bool intersect(const SbLine &l, SbVec3f &intersection) const
Intersect line and plane, returning TRUE if there is an intersection, FALSE if line is parallel to pl...
float getDistanceFromOrigin() const
Returns distance from origin to plane.
Definition: SbLinear.h:1398
float getDistance(const SbVec3f &point) const
Returns the distance of the point to the plane.
void transform(const SbMatrix &matrix)
Transforms the plane by the given matrix.
const SbVec3f & getNormal() const
Returns normal vector to plane.
Definition: SbLinear.h:1396
SbPlane()
Default constructor.
Definition: SbLinear.h:1363
bool isInHalfSpace(const SbVec3f &point) const
Returns TRUE if the given point is within the half-space defined by the plane.
SbPlane(const SbVec3f &n, const SbVec3f &p)
Construct a plane given normal and a point to pass through Orientation is given by the normal vector ...
void offset(float d)
Offset a plane by a given distance.
SbPlane(const SbVec3f &p0, const SbVec3f &p1, const SbVec3f &p2)
Construct a plane given three points.
Class for representing a rotation.
Definition: SbLinear.h:678
SbRotation()
Default constructor, initialized to identity.
Definition: SbLinear.h:682
static SbRotation slerp(const SbRotation &rot0, const SbRotation &rot1, float t)
Spherical linear interpolation: as t goes from 0 to 1, returned value goes from rot0 to rot1.
void getValue(SbMatrix &matrix) const
Returns corresponding 4x4 rotation matrix.
SbVec3f getAxis() const
Returns corresponding 3D rotation axis vector.
Definition: SbLinear.h:731
bool equals(const SbRotation &r, float tolerance) const
Equality comparison within given tolerance em the square of the length of the maximum distance betwee...
const float * getValue() const
Returns pointer to array of 4 components defining quaternion.
Definition: SbLinear.h:714
SbVec3f transformPoint(const SbVec3f &src) const
Multiplies the given vector by the matrix of this rotation.
Definition: SbLinear.h:776
SbRotation & invert()
Changes a rotation to be its inverse.
void getValue(SbVec3f &axis, float &radians) const
Returns corresponding 3D rotation axis vector and angle in radians.
SbRotation(const SbVec3f &rotateFrom, const SbVec3f &rotateTo)
Constructors for rotation.
Definition: SbLinear.h:710
SbRotation(float q0, float q1, float q2, float q3)
Definition: SbLinear.h:690
SbRotation & setValue(const SbVec3f &axis, float radians)
Sets value of vector from 3D rotation axis vector and angle in radians.
void scaleAngle(float scaleFactor)
Keep the axis the same.
SbMatrix getMatrix() const
Returns corresponding 4x4 rotation matrix.
void multVec(const SbVec3f &src, SbVec3f &dst) const
Multiplies the given vector by the matrix of this rotation.
SbRotation & setValue(const SbMatrix &m)
Sets value of rotation from a rotation matrix.
SbRotation & setValue(const float q[4])
Sets value of rotation from array of 4 components of a quaternion.
float getAngle() const
Returns corresponding angle in radians.
Definition: SbLinear.h:733
SbRotation(const SbVec3f &axis, float radians)
Definition: SbLinear.h:698
SbRotation(const SbMatrix &m)
Definition: SbLinear.h:694
void getValue(float &q0, float &q1, float &q2, float &q3) const
Returns 4 individual components of rotation quaternion.
SbRotation(const float v[4])
Definition: SbLinear.h:686
SbRotation & setValue(const SbVec3f &rotateFrom, const SbVec3f &rotateTo)
Sets rotation to rotate one direction vector to another.
SbRotation inverse() const
Returns the inverse of a rotation.
Definition: SbLinear.h:739
SbRotation & setValue(float q0, float q1, float q2, float q3)
Sets value of rotation from 4 individual components of a quaternion.
static SbRotation identity()
Returns a null rotation.
Definition: SbLinear.h:788
Class for representing a sphere.
Definition: SbLinear.h:1489
void setRadius(float r)
Set just the center or radius.
const SbVec3f & getCenter() const
Return the center and radius.
Definition: SbLinear.h:1507
SbSphere()
Constructors.
Definition: SbLinear.h:1493
void circumscribe(const SbBox3f &box)
Return a sphere containing a given box.
void setValue(const SbVec3f &c, float r)
Change the center and radius.
void setCenter(const SbVec3f &c)
Set just the center or radius.
SbSphere(const SbVec3f &c, float r)
Construct a sphere given center and radius.
float getRadius() const
Return the center and radius.
Definition: SbLinear.h:1509
bool intersect(const SbLine &l, SbVec3f &enter, SbVec3f &exit) const
bool intersect(const SbLine &l, SbVec3f &intersection) const
Intersect line and sphere, returning TRUE if there is an intersection.
2D vector class.
Definition: SbLinear.h:246
float normalize()
Changes vector to be unit length.
bool equals(const SbVec2f v, float tolerance) const
Equality comparison within given tolerance em the square of the length of the maximum distance betwee...
SbVec2f()
Default constructor.
Definition: SbLinear.h:250
const float * getValue() const
Returns vector components.
Definition: SbLinear.h:262
void negate()
Negates each component of vector in place.
void getValue(float &x, float &y) const
Returns vector components.
SbVec2f(float x, float y)
Constructor given vector components.
Definition: SbLinear.h:256
float dot(const SbVec2f &v) const
Returns dot (inner) product of vector and another vector.
SbVec2f & setValue(const float v[2])
Sets the vector components.
float length() const
Returns geometric length of vector.
SbVec2f(const float v[2])
Constructor given vector components.
Definition: SbLinear.h:253
SbVec2f & setValue(float x, float y)
Sets the vector components.
2D vector class.
Definition: SbLinear.h:354
SbVec2s(short x, short y)
Constructor given 2 components.
Definition: SbLinear.h:364
void getValue(short &x, short &y) const
Returns vector components.
SbVec2s()
Default constructor.
Definition: SbLinear.h:358
SbVec2s & setValue(const short v[2])
Sets vector components.
SbVec2s(const short v[2])
Constructor given 2 components.
Definition: SbLinear.h:361
SbVec2s & setValue(short x, short y)
Sets vector components.
void negate()
Negates each component of vector in place.
const short * getValue() const
Returns vector components.
Definition: SbLinear.h:370
int32_t dot(const SbVec2s &v) const
Returns dot (inner) product of vector and another vector.
3D vector class.
Definition: SbLinear.h:120
SbVec3f cross(const SbVec3f &v) const
Returns right-handed cross product of vector and another vector.
SbVec3f & setValue(const SbVec3f &barycentic, const SbVec3f &v0, const SbVec3f &v1, const SbVec3f &v2)
Sets value of vector to be convex combination of 3 other vectors, using barycentic coordinates.
float length() const
Returns geometric length of vector.
float normalize()
Changes vector to be unit length, returning the length before normalization.
void getValue(float &x, float &y, float &z) const
Returns vector components.
SbVec3f(const float v[3])
Constructor given vector components.
Definition: SbLinear.h:127
SbVec3f(SbPlane &p0, SbPlane &p1, SbPlane &p2)
Constructor given 3 planes.
SbVec3f & setValue(const float v[3])
Sets the vector components.
Definition: SbLinear.h:159
bool equals(const SbVec3f v, float tolerance) const
Equality comparison within given tolerance em the square of the length of the maximum distance betwee...
float dot(const SbVec3f &v) const
Returns dot (inner) product of vector and another vector.
void negate()
Negates each component of vector in place.
SbVec3f(float x, float y, float z)
Constructor given vector components.
Definition: SbLinear.h:131
SbVec3f & setValue(float x, float y, float z)
Sets the vector components.
Definition: SbLinear.h:163
SbVec3f()
Default constructor.
Definition: SbLinear.h:124
SbVec3f getClosestAxis() const
Returns principal axis that is closest (based on maximum dot product) to this vector.
const float * getValue() const
Returns vector components.
Definition: SbLinear.h:144
3D vector used to represet points or directions.
Definition: SbLinear.h:454
SbVec3s(const short v[3])
Constructor given an array of 3 components.
Definition: SbLinear.h:461
void getValue(short &x, short &y, short &z) const
Returns vector components.
const short * getValue() const
Returns vector components.
Definition: SbLinear.h:470
void negate()
Negates each component of vector in place.
int32_t dot(const SbVec3s &v) const
Returns dot (inner) product of vector and another vector.
SbVec3s & setValue(short x, short y, short z)
Sets value of vector from 3 individual components.
SbVec3s()
Default constructor.
Definition: SbLinear.h:458
SbVec3s(short x, short y, short z)
Constructor given 3 individual components.
Definition: SbLinear.h:464
SbVec3s & setValue(const short v[3])
Sets value of vector from array of 3 components.
4D vector class.
Definition: SbLinear.h:559
float length() const
Returns geometric length of vector.
void negate()
Negates each component of vector in place.
float normalize()
Changes vector to be unit length.
SbVec4f & setValue(const float v[4])
Sets the vector components.
const float * getValue() const
Returns vector components.
Definition: SbLinear.h:581
void getReal(SbVec3f &v) const
Returns the real portion of the vector by dividing by the fourth value.
void getValue(float &x, float &y, float &z, float &w) const
Returns vector components.
SbVec3f getReal() const
Returns the real portion of the vector by dividing by the fourth value.
Definition: SbLinear.h:578
SbVec4f(const float v[4])
Constructor given vector components.
Definition: SbLinear.h:566
SbVec4f()
Default constructor.
Definition: SbLinear.h:563
SbVec4f(float x, float y, float z, float w)
Constructor given vector components.
Definition: SbLinear.h:569
SbVec4f & setValue(float x, float y, float z, float w)
Sets the vector components.
float dot(const SbVec4f &v) const
Returns dot (inner) product of vector and another vector.
bool equals(const SbVec4f v, float tolerance) const
Equality comparison within given tolerance em the square of the length of the maximum distance betwee...
3D viewing volume class.
Definition: SbLinear.h:1058
float nearDist
distance to near plane
Definition: SbLinear.h:1237
void transform(const SbMatrix &matrix)
Transforms the view volume by the given matrix.
const SbVec3f & getProjectionDirection() const
Returns projection information.
Definition: SbLinear.h:1215
SbVec3f lrf
Definition: SbLinear.h:1240
void projectPointToLine(const SbVec2f &pt, SbLine &line) const
Maps a 2d point (in 0 <= x,y <= 1) to a 3d line.
ProjectionType getProjectionType() const
Returns projection information.
Definition: SbLinear.h:1209
void ortho(float left, float right, float bottom, float top, float nearVal, float farVal)
Sets up an orthographic view volume with the given sides.
SbRotation getAlignRotation(bool rightAngleOnly=FALSE) const
Returns a rotation that would align a viewed object so that its positive x-axis (of its object space)...
void getMatrices(SbMatrix &affine, SbMatrix &proj) const
Returns two matrices corresponding to the view volume.
float getDepth() const
Returns bounds of viewing frustum.
Definition: SbLinear.h:1228
SbVec3f projDir
Definition: SbLinear.h:1236
SbViewVolume()
Constructor and destructor.
float getWorldToScreenScale(const SbVec3f &worldCenter, float normRadius) const
Returns a scale factor that would scale a unit sphere centered at worldCenter so that it would appear...
ProjectionType type
Definition: SbLinear.h:1231
bool intersect(const SbVec3f &p0, const SbVec3f &p1, SbVec3f &closestPoint) const
Returns TRUE if line segment between 2 points may intersect volume.
void projectToScreen(const SbVec3f &src, SbVec3f &dst) const
Maps the 3D point in world coordinates to a 2D point in normalized screen coordinates (0 <= x,...
SbViewVolume narrow(const SbBox3f &box) const
Narrow a view volume by the given box.
SbMatrix getProjectionMatrix() const
Returns the projection matrix.
Definition: SbLinear.h:1076
float nearToFar
distance between z clips
Definition: SbLinear.h:1238
ProjectionType
Return projection information.
Definition: SbLinear.h:1203
SbVec3f projectToScreen(const SbVec3f &src) const
Maps the 3D point in world coordinates to a 2D point in normalized screen coordinates (0 <= x,...
Definition: SbLinear.h:1109
void translateCamera(const SbVec3f &v)
Translate the camera viewpoint.
void rotateCamera(const SbRotation &q)
Rotate the camera view direction.
void scale(float factor)
Scales width and height of view volume by given factor.
SbViewVolume narrow(float left, float bottom, float right, float top) const
Given a view volume, this narrows the view to the given sub-rectangle of the near plane.
void scaleHeight(float ratio)
Scales view volume to be the given ratio of its current height, leaving the resulting view volume cen...
float getHeight() const
Returns bounds of viewing frustum.
Definition: SbLinear.h:1226
SbVec3f getPlanePoint(float distFromEye, const SbVec2f &normPoint) const
Returns the projection of a given point in normalized screen coordinates (see projectToScreen()) onto...
void projectPointToLine(const SbVec2f &pt, SbVec3f &line0, SbVec3f &line1) const
~SbViewVolume()
Constructor and destructor.
Definition: SbLinear.h:1064
void scaleWidth(float ratio)
Scales view volume to be the given ratio of its current width, leaving the resulting view volume cent...
SbPlane getPlane(float distFromEye) const
Returns a plane parallel to the near (or far) plane of the view volume at a given distance from the p...
const SbVec3f & getProjectionPoint() const
Returns projection information.
Definition: SbLinear.h:1212
bool intersect(const SbVec3f &point) const
Returns TRUE if view volume contains point.
SbLine projectPointToLine(const SbVec2f &pt) const
Maps a 2d point (in 0 <= x,y <= 1) to a 3d line.
void perspective(float fovy, float aspect, float nearVal, float farVal)
Sets up a perspective view volume with the given field of view and aspect ratio.
float getWidth() const
Returns bounds of viewing frustum.
Definition: SbLinear.h:1224
SbVec3f projPoint
Note that there is redundant info in this data structure and its elements should not be changed by ha...
Definition: SbLinear.h:1235
SbMatrix getMatrix() const
Like the method above, but returns the affine and projection parts together in one matrix (i....
float getFarDist() const
Returns distance from projection point to far plane.
Definition: SbLinear.h:1221
SbVec3f ulf
Definition: SbLinear.h:1241
SbVec3f getSightPoint(float distFromEye) const
Returns the point along the line of sight at the given distance from the projection point (eye).
bool intersect(const SbBox3f &box) const
Returns TRUE if bounding box may intersect volume.
SbVec2f projectBox(const SbBox3f &box) const
Projects the given 3D bounding box onto the near plane and returns the size (in normalized screen coo...
SbMatrix getCameraSpaceMatrix() const
Returns a matrix that transforms the view volume into camera space: it translates the view volume so ...
SbMatrix getViewingMatrix() const
Returns the affine viewing matrix.
Definition: SbLinear.h:1073
SbVec3f llf
Definition: SbLinear.h:1239
SbVec3f zVector() const
Returns the positive z axis in eye space.
SbViewVolume zNarrow(float nearVal, float farVal) const
Returns a narrowed view volume which contains as tightly as possible the given interval on the z axis...
float getNearDist() const
Returns distance from projection point to near plane.
Definition: SbLinear.h:1218
bool outsideTest(const SbPlane &p, const SbVec3f &min, const SbVec3f &max) const
Returns TRUE if the bounding box defined by min,max is totally outside plane p.