29 #include <Inventor/SbBasic.h>
31 #include <Inventor/errors/SoDebugError.h>
42 SbVec2f(
const float v[2]) { vec[0] = v[0]; vec[1] = v[1]; }
43 SbVec2f(
float x,
float y) { vec[0] = x; vec[1] = y; }
49 SbVec2f &
setValue(
const float v[2]) { vec[0] = v[0]; vec[1] = v[1];
return *
this; }
56 const float *
getValue(
void)
const {
return vec; }
57 void getValue(
float & x,
float & y)
const { x = vec[0]; y = vec[1]; }
59 float & operator [] (
int i) {
return vec[i]; }
60 const float & operator [] (
int i)
const {
return vec[i]; }
62 float dot(
const SbVec2f & v)
const {
return vec[0] * v[0] + vec[1] * v[1]; }
63 SbBool equals(
const SbVec2f & v,
float tolerance)
const;
64 float length(
void)
const;
65 float sqrLength(
void)
const {
return vec[0] * vec[0] + vec[1] * vec[1]; }
66 void negate(
void) { vec[0] = -vec[0]; vec[1] = -vec[1]; }
67 float normalize(
void);
69 SbVec2f & operator *= (
float d) { vec[0] *= d; vec[1] *= d;
return *
this; }
70 SbVec2f & operator /= (
float d) { SbDividerChk(
"SbVec2f::operator/=(float)", d);
return operator *= (1.0f / d); }
71 SbVec2f & operator += (
const SbVec2f & v) { vec[0] += v[0]; vec[1] += v[1];
return *
this; }
72 SbVec2f & operator -= (
const SbVec2f & v) { vec[0] -= v[0]; vec[1] -= v[1];
return *
this; }
75 void print(FILE * fp)
const;
83 SbVec2f val(v); val *= d;
return val;
87 SbVec2f val(v); val *= d;
return val;
91 SbDividerChk(
"operator/(SbVec2f,float)", d);
92 SbVec2f val(v); val /= d;
return val;
96 SbVec2f v(v1); v += v2;
return v;
100 SbVec2f v(v1); v -= v2;
return v;
104 return ((v1[0] == v2[0]) && (v1[1] == v2[1]));
113 #endif // !COIN_SBVEC2F_H