29 #include <Inventor/SbBasic.h>
31 #include <Inventor/errors/SoDebugError.h>
43 SbVec3f(
const float v[3]) { vec[0] = v[0]; vec[1] = v[1]; vec[2] = v[2]; }
44 SbVec3f(
float x,
float y,
float z) { vec[0] = x; vec[1] = y; vec[2] = z; }
51 SbVec3f &
setValue(
const float v[3]) { vec[0] = v[0]; vec[1] = v[1]; vec[2] = v[2];
return *
this; }
52 SbVec3f &
setValue(
float x,
float y,
float z) { vec[0] = x; vec[1] = y; vec[2] = z;
return *
this; }
62 const float *
getValue(
void)
const {
return vec; }
63 void getValue(
float & x,
float & y,
float & z)
const { x = vec[0]; y = vec[1]; z = vec[2]; }
65 float & operator [] (
int i) {
return vec[i]; }
66 const float & operator [] (
int i)
const {
return vec[i]; }
68 SbBool equals(
const SbVec3f & v,
float tolerance)
const;
70 float dot(
const SbVec3f & v)
const {
return vec[0] * v[0] + vec[1] * v[1] + vec[2] * v[2]; }
71 SbVec3f getClosestAxis(
void)
const;
72 float length(
void)
const;
73 float sqrLength(
void)
const {
return vec[0] * vec[0] + vec[1] * vec[1] + vec[2] * vec[2]; }
74 float normalize(
void);
75 void negate(
void) { vec[0] = -vec[0]; vec[1] = -vec[1]; vec[2] = -vec[2]; }
77 SbVec3f & operator *= (
float d) { vec[0] *= d; vec[1] *= d; vec[2] *= d;
return *
this; }
78 SbVec3f & operator /= (
float d) { SbDividerChk(
"SbVec3f::operator/=(float)", d);
return operator *= (1.0f / d); }
79 SbVec3f & operator += (
const SbVec3f & v) { vec[0] += v[0]; vec[1] += v[1]; vec[2] += v[2];
return *
this; }
80 SbVec3f & operator -= (
const SbVec3f & v) { vec[0] -= v[0]; vec[1] -= v[1]; vec[2] -= v[2];
return *
this; }
81 SbVec3f operator - (
void)
const {
return SbVec3f(-vec[0], -vec[1], -vec[2]); }
83 void print(FILE * fp)
const;
91 SbVec3f val(v); val *= d;
return val;
95 SbVec3f val(v); val *= d;
return val;
99 SbDividerChk(
"operator/(SbVec3f,float)", d);
100 SbVec3f val(v); val /= d;
return val;
104 SbVec3f v(v1); v += v2;
return v;
108 SbVec3f v(v1); v -= v2;
return v;
112 return ((v1[0] == v2[0]) && (v1[1] == v2[1]) && (v1[2] == v2[2]));
119 #endif // !COIN_SBVEC3F_H