| 1 |
NAME SbVec4f SbV4f "" { 4D vector class } |
| 2 |
INCLUDE SbLinear.h |
| 3 |
DESC { |
| 4 |
4D vector class used to store homogeneous coordinates. This class is used |
| 5 |
in 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 SbVec4f \{ float vec[4]; \}; |
| 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; v1.vec[3] = 1.0; |
| 20 |
SbV4fSetX_Y_Z_W( v2, 1.0, 1.0, 1.0, 1,0 ); |
| 21 |
\.\.\. |
| 22 |
} |
| 23 |
|
| 24 |
BEGIN C++ |
| 25 |
METHOD "" SbVec4f() { Default constructor. } |
| 26 |
METHOD "" SbVec4f(const float v[4]) {} |
| 27 |
METHOD "" SbVec4f(float x, float y, float z, float w) { |
| 28 |
Constructor given vector components. |
| 29 |
} |
| 30 |
METHOD "" float dot(const SbVec4f &v) const { |
| 31 |
Returns dot (inner) product of vector and another vector. |
| 32 |
} |
| 33 |
END |
| 34 |
|
| 35 |
BEGIN C |
| 36 |
MACRO SbV4fDot(SbVec4f vec0, SbVec4f vec1) { |
| 37 |
Returns dot (inner) product of two vectors. |
| 38 |
} |
| 39 |
END |
| 40 |
|
| 41 |
METHOD "" SbBool equals(const SbVec4f v, float tolerance) const { |
| 42 |
Equality comparison within given tolerance \(em the square of the |
| 43 |
length of the maximum distance between the two vectors. |
| 44 |
} |
| 45 |
METHOD "" void getReal(SbVec3f &v) const { |
| 46 |
Returns the real portion of the vector by dividing by the fourth value. |
| 47 |
} |
| 48 |
|
| 49 |
BEGIN C++ |
| 50 |
METHOD "" const float *getValue() const {} |
| 51 |
METHOD "" void getValue(float &x, float &y, float &z, float &w) const { |
| 52 |
Returns vector components. |
| 53 |
} |
| 54 |
END |
| 55 |
|
| 56 |
BEGIN C |
| 57 |
MACRO SbV4fGetXYZW(float array[4], SbVec4f vec) {} |
| 58 |
MACRO SbV4fGetX_Y_Z_W(float x, float y, float z, float w, SbVec4f vec) { |
| 59 |
Returns vector components. |
| 60 |
} |
| 61 |
END |
| 62 |
|
| 63 |
BEGIN C++ |
| 64 |
METHOD "" float length() const { |
| 65 |
Returns geometric length of vector. |
| 66 |
} |
| 67 |
METHOD "" void negate() { |
| 68 |
Negates each component of vector in place. |
| 69 |
} |
| 70 |
END |
| 71 |
BEGIN C |
| 72 |
MACRO SbV4fLen(SbVec4f vec) { |
| 73 |
Returns geometric length of vector. |
| 74 |
} |
| 75 |
MACRO SbV4fNegate(SbVec4f vec) { |
| 76 |
Negates each component of vector in place. |
| 77 |
} |
| 78 |
END |
| 79 |
|
| 80 |
METHOD norm normalize() { |
| 81 |
Changes vector to be unit length. |
| 82 |
} |
| 83 |
|
| 84 |
BEGIN C |
| 85 |
MACRO SbV4fSetXYZW(SbVec4f vec, float array[4]) {} |
| 86 |
MACRO SbV4fSetX_Y_Z_W(SbVec4f vec, float x, float y, float z, float w) { |
| 87 |
Sets the vector components. |
| 88 |
} |
| 89 |
MACRO SbV4fAdd(SbVec4f dest, SbVec4f src1, SbVec4f src2) {} |
| 90 |
MACRO SbV4fSub(SbVec4f dest, SbVec4f src1, SbVec4f src2) { |
| 91 |
Component-wise binary vector addition and subtraction operators. |
| 92 |
} |
| 93 |
MACRO SbV4fMultBy(SbVec4f vec, float scalar) {} |
| 94 |
MACRO SbV4fDivBy(SbVec4f vec, float scalar) { |
| 95 |
Component-wise scalar multiplication and division operators. |
| 96 |
} |
| 97 |
END |
| 98 |
|
| 99 |
BEGIN C++ |
| 100 |
METHOD "" SbVec4f & setValue(const float v[4]) {} |
| 101 |
METHOD "" SbVec4f & setValue(float x, float y, float z, float w) { |
| 102 |
Sets the vector components. |
| 103 |
} |
| 104 |
METHOD "" float & operator [\|](int i) {} |
| 105 |
METHOD "" const float & operator [\|](int i) { |
| 106 |
Accesses indexed component of vector. |
| 107 |
} |
| 108 |
METHOD "" SbVec4f & operator *=(float d) {} |
| 109 |
METHOD "" SbVec4f & operator /=(float d) { |
| 110 |
Component-wise scalar multiplication and division operators. |
| 111 |
} |
| 112 |
METHOD "" SbVec4f & operator +=(const SbVec4f &u) {} |
| 113 |
METHOD "" SbVec4f & operator -=(const SbVec4f &u) { |
| 114 |
Component-wise vector addition and subtraction operators. |
| 115 |
} |
| 116 |
METHOD "" SbVec4f operator -() const { |
| 117 |
Nondestructive unary negation \(em returns a new vector. |
| 118 |
} |
| 119 |
METHOD "" SbVec4f operator *(const SbVec4f &v, float d) {} |
| 120 |
METHOD "" SbVec4f operator *(float d, const SbVec4f &v) {} |
| 121 |
METHOD "" SbVec4f operator /(const SbVec4f &v, float d) { |
| 122 |
Component-wise binary scalar multiplication and division operators. |
| 123 |
} |
| 124 |
METHOD "" SbVec4f operator +(const SbVec4f &v1, const SbVec4f &v2) {} |
| 125 |
METHOD "" SbVec4f operator -(const SbVec4f &v1, const SbVec4f &v2) { |
| 126 |
Component-wise binary vector addition and subtraction operators. |
| 127 |
} |
| 128 |
END |
| 129 |
METHOD "" int operator ==(const SbVec4f &v1, const SbVec4f &v2) {} |
| 130 |
METHOD "" int operator !=(const SbVec4f &v1, const SbVec4f &v2) { |
| 131 |
Equality comparison operators. |
| 132 |
} |
| 133 |
ALSO { SbVec2f, SbVec3f, SbVec2s, SbRotation } |