38 #include <Inventor/SbBasic.h>
39 #include <Inventor/SbString.h>
41 #include <Inventor/errors/SoDebugError.h>
52 SbVec2f(
const float v[2]) { vec[0] = v[0]; vec[1] = v[1]; }
53 SbVec2f(
float x,
float y) { vec[0] = x; vec[1] = y; }
59 SbVec2f &
setValue(
const float v[2]) { vec[0] = v[0]; vec[1] = v[1];
return *
this; }
66 const float *
getValue(
void)
const {
return vec; }
67 void getValue(
float & x,
float & y)
const { x = vec[0]; y = vec[1]; }
69 float & operator [] (
int i) {
return vec[i]; }
70 const float & operator [] (
int i)
const {
return vec[i]; }
72 float dot(
const SbVec2f & v)
const {
return vec[0] * v[0] + vec[1] * v[1]; }
73 SbBool equals(
const SbVec2f & v,
float tolerance)
const;
74 float length(
void)
const;
75 float sqrLength(
void)
const {
return vec[0] * vec[0] + vec[1] * vec[1]; }
76 void negate(
void) { vec[0] = -vec[0]; vec[1] = -vec[1]; }
77 float normalize(
void);
79 SbVec2f & operator *= (
float d) { vec[0] *= d; vec[1] *= d;
return *
this; }
80 SbVec2f & operator /= (
float d) { SbDividerChk(
"SbVec2f::operator/=(float)", d);
return operator *= (1.0f / d); }
81 SbVec2f & operator += (
const SbVec2f & v) { vec[0] += v[0]; vec[1] += v[1];
return *
this; }
82 SbVec2f & operator -= (
const SbVec2f & v) { vec[0] -= v[0]; vec[1] -= v[1];
return *
this; }
86 SbBool fromString(
const SbString & str);
88 void print(FILE * fp)
const;
96 SbVec2f val(v); val *= d;
return val;
100 SbVec2f val(v); val *= d;
return val;
104 SbDividerChk(
"operator/(SbVec2f,float)", d);
105 SbVec2f val(v); val /= d;
return val;
109 SbVec2f v(v1); v += v2;
return v;
113 SbVec2f v(v1); v -= v2;
return v;
117 return ((v1[0] == v2[0]) && (v1[1] == v2[1]));
126 #endif // !COIN_SBVEC2F_H