2 #include "oxygine-include.h" 39 bool operator == (
const VectorT3& r)
const;
40 bool operator != (
const VectorT3& r)
const;
49 inline T& operator[](
int i) {
return m[i];}
50 inline const T& operator[](
int i)
const {
return m[i];}
77 bool VectorT3<T>::operator == (
const VectorT3<T>& r)
const 79 if (x == r.x && y == r.y && z == r.z)
85 bool VectorT3<T>::operator != (
const VectorT3<T>& r)
const 87 return !(r == (*this));
91 VectorT3<T>::VectorT3()
95 VectorT3<T>::VectorT3(
const T* p):
96 x(p[0]), y(p[1]), z(p[2])
102 VectorT3<T>::VectorT3(T X, T Y, T Z):
108 VectorT3<T>& VectorT3<T>::operator+=(
const VectorT3& v)
110 x += v.x; y += v.y; z += v.z;
return (*
this);
114 VectorT3<T>& VectorT3<T>::operator-=(
const VectorT3& v)
116 x -= v.x; y -= v.y; z -= v.z;
return (*
this);
120 VectorT3<T> VectorT3<T>::operator + (
const VectorT3& v)
const 122 return VectorT3(x + v.x, y + v.y, z + v.z);
126 VectorT3<T> VectorT3<T>::operator - (
const VectorT3& v)
const 128 return VectorT3(x - v.x, y - v.y, z - v.z);
132 VectorT3<T> VectorT3<T>::operator - ()
const 134 return VectorT3(-x, -y, -z);
138 VectorT3<T> VectorT3<T>::operator * (T s)
const 140 return VectorT3(x * s, y * s, z * s);
144 VectorT3<T> VectorT3<T>::operator / (T v)
const 147 return VectorT3(x * s, y * s, z * s);
152 VectorT3<T>& VectorT3<T>::operator*=(T s)
154 x *= s; y *= s; z *= s;
return (*
this);
158 VectorT3<T>& VectorT3<T>::operator/=(T s)
161 x *= is; y *= is; z *= is;
return (*
this);
165 void VectorT3<T>::normalize()
167 normalize(*
this, *
this);
171 T VectorT3<T>::length()
const 173 return scalar::sqrt(x * x + y * y + z * z);
177 T VectorT3<T>::dot(
const VectorT3& p)
const 179 return VectorT3<T>::dot(*
this, p);
184 inline VectorT3<T>& VectorT3<T>::cross(VectorT3& out,
const VectorT3& v1,
const VectorT3& v2)
186 out.x = v1.y * v2.z - v1.z * v2.y;
187 out.y = v1.z * v2.x - v1.x * v2.z;
188 out.z = v1.x * v2.y - v1.y * v2.x;
193 inline void VectorT3<T>::clamp(
const VectorT3& min,
const VectorT3& max)
211 inline T VectorT3<T>::dot(
const VectorT3& v1,
const VectorT3& v2)
213 return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z;
217 inline VectorT3<T>& VectorT3<T>::normalize(VectorT3<T>& out,
const VectorT3<T>& v)
219 T norm = T(1.0) / scalar::sqrt(v.x * v.x + v.y * v.y + v.z * v.z);
228 inline VectorT3<T>& VectorT3<T>::normalFromPoints(VectorT3& out,
const VectorT3& v1,
const VectorT3& v2,
const VectorT3& v3)
230 vector3 b1 = v1 - v2;
231 vector3 b2 = v3 - v2;
233 vector3::cross(&cross, b2, b1);
234 vector3::normalize(&cross, cross);
243 typedef VectorT3<float> Vector3;
244 typedef VectorT3<double> VectorD3;
–oxgl-end–!
Definition: Actor.h:14