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)
const float Epsilon
Smallest number that can be represented with a 32 bit float (may not match your compiler/os varient) ...
cVector3(float n)
Constructor, initializes all 3 axes to the same value.
cVector3(void)
Default constructor, initializes everything to 0.
cVector3 cross(const cVector3 &other) const
Returns the cross product of this vector with the input vector.
float length() const
Returns the length (magnitude) of the vector.
float dot(const cVector3 &other) const
Returns the dot product of this vector with the input vector.
bool float_equals(const float a, const float b)
Internal function that compares two floats while keeping the Epsilon in mind.
Class for manipulating vectors in 3D space.
void normalize()
Forces the current vector to have a length of 1 while preserving the ratio of components.
Main namespace for the entire cAudio library.