| 1 |
NAME SbVec3f SbV3f "" { 3D vector class } |
| 2 |
INCLUDE SbLinear.h |
| 3 |
DESC { |
| 4 |
3D vector class used to store 3D vectors and points. This class is used |
| 5 |
throughout Inventor for arguments and return values. |
| 6 |
\- |
| 7 |
This object does not have \mCreate\. or \mDelete\. |
| 8 |
functions because it is considered a simple datatype; instances of |
| 9 |
this class may be declared directly as local or global variables in C. |
| 10 |
C programmers can access the components of the vector as though it were |
| 11 |
a simple structure or use the access and operation functions described |
| 12 |
in this reference page: |
| 13 |
\b\k |
| 14 |
struct SbVec3f \{ float vec[3]; \}; |
| 15 |
|
| 16 |
SbVec2f v1, v2; |
| 17 |
|
| 18 |
/* The next two lines produce equivalent vectors. */ |
| 19 |
v1.vec[0] = 1.0; v1.vec[1] = 1.0; v1.vec[2] = 1.0; |
| 20 |
SbV3fSetX_Y_Z( v2, 1.0, 1.0, 1.0 ); |
| 21 |
\.\.\. |
| 22 |
} |
| 23 |
|
| 24 |
BEGIN C++ |
| 25 |
METHOD "" SbVec3f() { Default constructor. } |
| 26 |
METHOD "" SbVec3f(const float v[3]) {} |
| 27 |
METHOD "" SbVec3f(float x, float y, float z) { |
| 28 |
Constructor given vector components. |
| 29 |
} |
| 30 |
METHOD "" SbVec3f(SbPlane &p0, SbPlane &p1, SbPlane &p2) { |
| 31 |
Constructor given 3 planes. |
| 32 |
} |
| 33 |
END |
| 34 |
|
| 35 |
METHOD "" SbVec3f cross(const SbVec3f &v) const { |
| 36 |
Returns right-handed cross product of vector and another vector. |
| 37 |
} |
| 38 |
|
| 39 |
BEGIN C++ |
| 40 |
METHOD "" float dot(const SbVec3f &v) const { |
| 41 |
Returns dot (inner) product of vector and another vector. |
| 42 |
} |
| 43 |
END |
| 44 |
|
| 45 |
BEGIN C |
| 46 |
MACRO SbV3fDot(SbVec3f vec0, SbVec3f vec1) { |
| 47 |
Returns dot (inner) product of two vectors. |
| 48 |
} |
| 49 |
END |
| 50 |
|
| 51 |
METHOD "" SbBool equals(const SbVec3f v, float tolerance) const { |
| 52 |
Equality comparison within given tolerance \(em the square of the |
| 53 |
length of the maximum distance between the two vectors. |
| 54 |
} |
| 55 |
METHOD "" SbVec3f getClosestAxis() const { |
| 56 |
Returns principal axis that is closest (based on maximum dot |
| 57 |
product) to this vector. |
| 58 |
} |
| 59 |
|
| 60 |
BEGIN C++ |
| 61 |
METHOD "" const float *getValue() const {} |
| 62 |
METHOD "" void getValue(float &x, float &y, float &z) const { |
| 63 |
Returns vector components. |
| 64 |
} |
| 65 |
END |
| 66 |
|
| 67 |
BEGIN C |
| 68 |
MACRO SbV3fGetXYZ(float array[3], SbVec3f vec) {} |
| 69 |
MACRO SbV3fGetX_Y_Z(float x, float y, float z, SbVec3f vec) { |
| 70 |
Returns vector components. |
| 71 |
} |
| 72 |
END |
| 73 |
|
| 74 |
BEGIN C++ |
| 75 |
METHOD "" float length() const { |
| 76 |
Returns geometric length of vector. |
| 77 |
} |
| 78 |
METHOD "" void negate() { |
| 79 |
Negates each component of vector in place. |
| 80 |
} |
| 81 |
END |
| 82 |
BEGIN C |
| 83 |
MACRO SbV3fLen(SbVec3f vec) { |
| 84 |
Returns geometric length of vector. |
| 85 |
} |
| 86 |
MACRO SbV3fNegate(SbVec3f vec) { |
| 87 |
Negates each component of vector in place. |
| 88 |
} |
| 89 |
MACRO SbV3fSetXYZ(SbVec3f vec, float array[3]) {} |
| 90 |
MACRO SbV3fSetX_Y_Z(SbVec3f vec, float x, float y, float z) { |
| 91 |
Sets the vector components. |
| 92 |
} |
| 93 |
MACRO SbV3fMultBy(SbVec3f vec, float scalar) {} |
| 94 |
MACRO SbV3fDivBy(SbVec3f vec, float scalar) { |
| 95 |
Component-wise scalar multiplication and division operators. |
| 96 |
} |
| 97 |
MACRO SbV3fAdd(SbVec3f dest, SbVec3f src1, SbVec3f src2) {} |
| 98 |
MACRO SbV3fSub(SbVec3f dest, SbVec3f src1, SbVec3f src2) { |
| 99 |
Component-wise binary vector addition and subtraction operators. |
| 100 |
} |
| 101 |
END |
| 102 |
METHOD norm float normalize() { |
| 103 |
Changes vector to be unit length, returning the length before normalization. |
| 104 |
} |
| 105 |
BEGIN C++ |
| 106 |
METHOD "" SbVec3f & setValue(const float v[3]) {} |
| 107 |
METHOD "" SbVec3f & setValue(float x, float y, float z) { |
| 108 |
Sets the vector components. |
| 109 |
} |
| 110 |
METHOD "" SbVec3f & setValue(const SbVec3f &barycentic, |
| 111 |
const SbVec3f &v0, const SbVec3f &v1, const SbVec3f &v2) { |
| 112 |
Sets value of vector as the weighted average of 3 other vectors. |
| 113 |
} |
| 114 |
METHOD "" float & operator [\|](int i) {} |
| 115 |
METHOD "" const float & operator [\|](int i) { |
| 116 |
Accesses indexed component of vector. |
| 117 |
} |
| 118 |
METHOD "" SbVec3f & operator *=(float d) {} |
| 119 |
METHOD "" SbVec3f & operator /=(float d) { |
| 120 |
Component-wise scalar multiplication and division operators. |
| 121 |
} |
| 122 |
METHOD "" SbVec3f & operator +=(const SbVec3f &u) {} |
| 123 |
METHOD "" SbVec3f & operator -=(const SbVec3f &u) { |
| 124 |
Component-wise vector addition and subtraction operators. |
| 125 |
} |
| 126 |
METHOD "" SbVec3f operator -() const { |
| 127 |
Nondestructive unary negation \(em returns a new vector. |
| 128 |
} |
| 129 |
METHOD "" SbVec3f operator *(const SbVec3f &v, float d) {} |
| 130 |
METHOD "" SbVec3f operator *(float d, const SbVec3f &v) {} |
| 131 |
METHOD "" SbVec3f operator /(const SbVec3f &v, float d) { |
| 132 |
Component-wise binary scalar multiplication and division operators. |
| 133 |
} |
| 134 |
METHOD "" SbVec3f operator +(const SbVec3f &v1, const SbVec3f &v2) {} |
| 135 |
METHOD "" SbVec3f operator -(const SbVec3f &v1, const SbVec3f &v2) { |
| 136 |
Component-wise binary vector addition and subtraction operators. |
| 137 |
} |
| 138 |
END |
| 139 |
METHOD "" int operator ==(const SbVec3f &v1, const SbVec3f &v2) {} |
| 140 |
METHOD "" int operator !=(const SbVec3f &v1, const SbVec3f &v2) { |
| 141 |
Equality comparison operators. |
| 142 |
} |
| 143 |
ALSO { SbVec2f, SbVec4f, SbVec2s, SbRotation } |