13 const float Epsilon = std::numeric_limits<float>::epsilon();
32 cVector3(
float nx,
float ny,
float nz) : x(nx), y(ny), z(nz)
45 cVector3(
float* vector) : x(vector[0]), y(vector[1]), z(vector[2])
50 cVector3& operator=(
const cVector3& other) { x = other.x; y = other.y; z = other.z;
return *
this; }
52 cVector3& operator+=(
const cVector3& other) { x+=other.x; y+=other.y; z+=other.z;
return *
this; }
53 cVector3 operator+(
const float val)
const {
return cVector3(x + val, y + val, z + val); }
54 cVector3& operator+=(
const float val) { x+=val; y+=val; z+=val;
return *
this; }
57 cVector3& operator-=(
const cVector3& other) { x-=other.x; y-=other.y; z-=other.z;
return *
this; }
58 cVector3 operator-(
const float val)
const {
return cVector3(x - val, y - val, z - val); }
59 cVector3& operator-=(
const float val) { x-=val; y-=val; z-=val;
return *
this; }
62 cVector3& operator*=(
const cVector3& other) { x*=other.x; y*=other.y; z*=other.z;
return *
this; }
63 cVector3 operator*(
const float v)
const {
return cVector3(x * v, y * v, z * v); }
64 cVector3& operator*=(
const float v) { x*=v; y*=v; z*=v;
return *
this; }
67 cVector3& operator/=(
const cVector3& other) { x/=other.x; y/=other.y; z/=other.z;
return *
this; }
68 cVector3 operator/(
const float v)
const {
float i=(float)1.0/v;
return cVector3(x * i, y * i, z * i); }
69 cVector3& operator/=(
const float v) {
float i=(float)1.0/v; x*=i; y*=i; z*=i;
return *
this; }
71 bool operator<=(
const cVector3& other)
const {
return x<=other.x && y<=other.y && z<=other.z;}
72 bool operator>=(
const cVector3& other)
const {
return x>=other.x && y>=other.y && z>=other.z;}
73 bool operator<(
const cVector3& other)
const {
return x<other.x && y<other.y && z<other.z;}
74 bool operator>(
const cVector3& other)
const {
return x>other.x && y>other.y && z>other.z;}
76 bool operator==(
const cVector3& other)
const
83 bool operator!=(
const cVector3& other)
const
90 operator const float*()
const {
return &x; }
92 operator float*() {
return &x; }
94 float operator[] (
int i )
const {
return ( (
float* ) &x ) [i]; }
96 float &operator[] (
int i ) {
return ( (
float* ) &x ) [i]; }
101 return sqrtf( x*x + y*y + z*z );
107 float invLen = 1.0f /
length();
116 return ( x * other.x + y * other.y + z * other.z );
122 return cVector3( y * other.z - z * other.y, z * other.x - x * other.z, x * other.y - y * other.x );
126 void set(
float nx,
float ny,
float nz )
147 void getAsArray(
float* output)