CSEngine
Loading...
Searching...
No Matches
CSE::Vector3< T > Class Template Reference

Public Member Functions

 Vector3 (T x, T y, T z)
 
void Set (T x, T y, T z)
 
void Normalize ()
 
Vector3 Normalized () const
 
Vector3 Cross (const Vector3 &v) const
 
Dot (const Vector3 &v) const
 
Vector3 operator+ (const Vector3 &v) const
 
void operator+= (const Vector3 &v)
 
void operator-= (const Vector3 &v)
 
void operator/= (T s)
 
Vector3 operator- (const Vector3 &v) const
 
Vector3 operator- () const
 
Vector3 operator* (T s) const
 
Vector3 operator/ (T s) const
 
bool operator== (const Vector3 &v) const
 
Vector3 Lerp (float t, const Vector3 &v) const
 
const T * Pointer () const
 
template<typename P >
P * Write (P *pData)
 

Static Public Member Functions

static Vector3 Lerp (float t, const Vector3 &a, Vector3 &b)
 
static float Distance (const Vector3 &a, const Vector3 &b)
 

Public Attributes

x
 
y
 
z
 

Detailed Description

template<typename T>
class CSE::Vector3< T >

Definition at line 118 of file Vector.h.

Constructor & Destructor Documentation

◆ Vector3() [1/2]

template<typename T >
CSE::Vector3< T >::Vector3 ( )
inline

Definition at line 121 of file Vector.h.

121: x(0.0f), y(0.0f), z(0.0f) {}

◆ Vector3() [2/2]

template<typename T >
CSE::Vector3< T >::Vector3 ( x,
y,
z 
)
inline

Definition at line 123 of file Vector.h.

123: x(x), y(y), z(z) {}

◆ ~Vector3()

template<typename T >
CSE::Vector3< T >::~Vector3 ( )
inline

Definition at line 125 of file Vector.h.

125{}

Member Function Documentation

◆ Cross()

template<typename T >
Vector3 CSE::Vector3< T >::Cross ( const Vector3< T > &  v) const
inline

Definition at line 146 of file Vector.h.

146 {
147 return Vector3(y * v.z - z * v.y,
148 z * v.x - x * v.z,
149 x * v.y - y * v.x);
150 }

◆ Distance()

template<typename T >
static float CSE::Vector3< T >::Distance ( const Vector3< T > &  a,
const Vector3< T > &  b 
)
inlinestatic

Definition at line 210 of file Vector.h.

210 {
211 return sqrtf(powf(a.x - b.x, 2) + powf(a.y - b.y, 2) + powf(a.z - b.z, 2));
212 }

◆ Dot()

template<typename T >
T CSE::Vector3< T >::Dot ( const Vector3< T > &  v) const
inline

Definition at line 152 of file Vector.h.

152 {
153 return x * v.x + y * v.y + z * v.z;
154 }

◆ Lerp() [1/2]

template<typename T >
static Vector3 CSE::Vector3< T >::Lerp ( float  t,
const Vector3< T > &  a,
Vector3< T > &  b 
)
inlinestatic

Definition at line 204 of file Vector.h.

204 {
205 return Vector3(a.x * (1 - t) + b.x * t,
206 a.y * (1 - t) + b.y * t,
207 a.z * (1 - t) + b.z * t);
208 }

◆ Lerp() [2/2]

template<typename T >
Vector3 CSE::Vector3< T >::Lerp ( float  t,
const Vector3< T > &  v 
) const
inline

Definition at line 198 of file Vector.h.

198 {
199 return Vector3(x * (1 - t) + v.x * t,
200 y * (1 - t) + v.y * t,
201 z * (1 - t) + v.z * t);
202 }

◆ Normalize()

template<typename T >
void CSE::Vector3< T >::Normalize ( )
inline

Definition at line 133 of file Vector.h.

133 {
134 float s = 1.0f / std::sqrt(x * x + y * y + z * z);
135 x *= s;
136 y *= s;
137 z *= s;
138 }

◆ Normalized()

template<typename T >
Vector3 CSE::Vector3< T >::Normalized ( ) const
inline

Definition at line 140 of file Vector.h.

140 {
141 Vector3 v = *this;
142 v.Normalize();
143 return v;
144 }

◆ operator*()

template<typename T >
Vector3 CSE::Vector3< T >::operator* ( s) const
inline

Definition at line 186 of file Vector.h.

186 {
187 return Vector3(x * s, y * s, z * s);
188 }

◆ operator+()

template<typename T >
Vector3 CSE::Vector3< T >::operator+ ( const Vector3< T > &  v) const
inline

Definition at line 156 of file Vector.h.

156 {
157 return Vector3(x + v.x, y + v.y, z + v.z);
158 }

◆ operator+=()

template<typename T >
void CSE::Vector3< T >::operator+= ( const Vector3< T > &  v)
inline

Definition at line 160 of file Vector.h.

160 {
161 x += v.x;
162 y += v.y;
163 z += v.z;
164 }

◆ operator-() [1/2]

template<typename T >
Vector3 CSE::Vector3< T >::operator- ( ) const
inline

Definition at line 182 of file Vector.h.

182 {
183 return Vector3(-x, -y, -z);
184 }

◆ operator-() [2/2]

template<typename T >
Vector3 CSE::Vector3< T >::operator- ( const Vector3< T > &  v) const
inline

Definition at line 178 of file Vector.h.

178 {
179 return Vector3(x - v.x, y - v.y, z - v.z);
180 }

◆ operator-=()

template<typename T >
void CSE::Vector3< T >::operator-= ( const Vector3< T > &  v)
inline

Definition at line 166 of file Vector.h.

166 {
167 x -= v.x;
168 y -= v.y;
169 z -= v.z;
170 }

◆ operator/()

template<typename T >
Vector3 CSE::Vector3< T >::operator/ ( s) const
inline

Definition at line 190 of file Vector.h.

190 {
191 return Vector3(x / s, y / s, z / s);
192 }

◆ operator/=()

template<typename T >
void CSE::Vector3< T >::operator/= ( s)
inline

Definition at line 172 of file Vector.h.

172 {
173 x /= s;
174 y /= s;
175 z /= s;
176 }

◆ operator==()

template<typename T >
bool CSE::Vector3< T >::operator== ( const Vector3< T > &  v) const
inline

Definition at line 194 of file Vector.h.

194 {
195 return x == v.x && y == v.y && z == v.z;
196 }

◆ Pointer()

template<typename T >
const T * CSE::Vector3< T >::Pointer ( ) const
inline

Definition at line 214 of file Vector.h.

214 {
215 return &x;
216 }

◆ Set()

template<typename T >
void CSE::Vector3< T >::Set ( x,
y,
z 
)
inline

Definition at line 127 of file Vector.h.

127 {
128 this->x = x;
129 this->y = y;
130 this->z = z;
131 }

◆ Write()

template<typename T >
template<typename P >
P * CSE::Vector3< T >::Write ( P *  pData)
inline

Definition at line 219 of file Vector.h.

219 {
220 Vector3<T>* pVector = (Vector3<T>*) pData;
221 *pVector++ = *this;
222 return (P*) pVector;
223 }

Member Data Documentation

◆ x

template<typename T >
T CSE::Vector3< T >::x

Definition at line 225 of file Vector.h.

◆ y

template<typename T >
T CSE::Vector3< T >::y

Definition at line 226 of file Vector.h.

◆ z

template<typename T >
T CSE::Vector3< T >::z

Definition at line 227 of file Vector.h.


The documentation for this class was generated from the following file: