sculpto
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
scl::math::vec4< T > Class Template Reference

#include <vec4.h>

Public Member Functions

SetX (T X)
 
SetY (T Y)
 
SetZ (T Z)
 
SetW (T W)
 
GetX () const
 
GetY () const
 
GetZ () const
 
GetW () const
 
 vec4 ()=default
 
 vec4 (T A)
 
 vec4 (T X, T Y, T Z, T W)
 
 vec4 (const vec3< T > &V, T W)
 
 vec4 (T X, const vec3< T > &V)
 
 vec4 (const vec4 &Other)
 
vec4operator= (const vec4 &Other)
 
bool operator== (const vec4 &Other)
 
const vec4 operator- () const
 
const vec4 operator+ (const vec4 &Other) const
 
const vec4operator+= (const vec4 &Other)
 
const vec4 operator+ (float Scalar) const
 
const vec4operator+= (float Scalar)
 
const vec4 operator- (const vec4 &Other) const
 
const vec4operator-= (const vec4 &Other)
 
const vec4 operator- (float Scalar) const
 
const vec4operator-= (float Scalar)
 
const vec4 operator* (const vec4 &Other) const
 
const vec4operator*= (const vec4 &Other)
 
const vec4 operator* (float Scalar) const
 
const vec4operator*= (float Scalar)
 
const vec4 operator/ (const vec4 &Other) const
 
const vec4operator/= (const vec4 &Other)
 
const vec4 operator/ (float Scalar) const
 
const vec4operator/= (float Scalar)
 
 operator T* ()
 
T & operator[] (int Index)
 
operator[] (int Index) const
 

Static Public Member Functions

static vec4 Zero ()
 
static vec4 Rnd (T Min=0, T Max=1)
 
static vec4 Min (const vec4 &A, const vec4 &B)
 
static vec4 Max (const vec4 &A, const vec4 &B)
 

Public Attributes

X { 0 }
 
Y { 0 }
 
Z { 0 }
 
W { 0 }
 

Detailed Description

template<typename T>
class scl::math::vec4< T >

Definition at line 25 of file vec4.h.

Constructor & Destructor Documentation

◆ vec4() [1/6]

template<typename T >
scl::math::vec4< T >::vec4 ( )
default

Vector construcotrs.

Default construcotr. All coodinates would ve set to zero.

◆ vec4() [2/6]

template<typename T >
scl::math::vec4< T >::vec4 ( A)
inlineexplicit
  • Vector constructor by one scalar. All corinates would be set to its value.
Parameters
A- scalar value of all cordinates.

Definition at line 60 of file vec4.h.

60: X(A), Y(A), Z(A), W(A) {}

◆ vec4() [3/6]

template<typename T >
scl::math::vec4< T >::vec4 ( X,
Y,
Z,
W 
)
inline
  • Vector constructor by three coordinates.
Parameters
X,Y- coordiantes of creating vector.

Definition at line 67 of file vec4.h.

67: X(X), Y(Y), Z(Z), W(W) {}

◆ vec4() [4/6]

template<typename T >
scl::math::vec4< T >::vec4 ( const vec3< T > &  V,
W 
)
inlineexplicit
  • Vector constructor by 3D vector and additional component.
Parameters
V- vector to get X, Y and Z coordinates
W- addition vector component

Definition at line 75 of file vec4.h.

75: X(V.GetX()), Y(V.GetY()), Z(V.GetZ()), W(W) {}

◆ vec4() [5/6]

template<typename T >
scl::math::vec4< T >::vec4 ( X,
const vec3< T > &  V 
)
inlineexplicit
  • Vector constructor by 3D vector and additional component.
Parameters
X- addition vector component
V- vector to get X, Y and Z coordinates

Definition at line 83 of file vec4.h.

83: X(X), Y(V.GetX()), Z(V.GetY()), W(V.GetZ()) {}

◆ vec4() [6/6]

template<typename T >
scl::math::vec4< T >::vec4 ( const vec4< T > &  Other)
inline
  • Vector copy constructor.
Parameters
Other- vector to copy from.

Definition at line 90 of file vec4.h.

91 {
92 if (this != &Other)
93 {
94 X = Other.X;
95 Y = Other.Y;
96 Z = Other.Z;
97 W = Other.W;
98 }
99 }

Member Function Documentation

◆ GetW()

template<typename T >
T scl::math::vec4< T >::GetW ( ) const
inline

W vector component getter function.

Definition at line 48 of file vec4.h.

48{ return W; }

◆ GetX()

template<typename T >
T scl::math::vec4< T >::GetX ( ) const
inline

X vector component getter function.

Definition at line 42 of file vec4.h.

42{ return X; }

◆ GetY()

template<typename T >
T scl::math::vec4< T >::GetY ( ) const
inline

Y vector component getter function.

Definition at line 44 of file vec4.h.

44{ return Y; }

◆ GetZ()

template<typename T >
T scl::math::vec4< T >::GetZ ( ) const
inline

Z vector component getter function.

Definition at line 46 of file vec4.h.

46{ return Z; }

◆ Max()

template<typename T >
static vec4 scl::math::vec4< T >::Max ( const vec4< T > &  A,
const vec4< T > &  B 
)
inlinestatic
  • Vector with compund of maximums of specified vectors components.
Parameters
A,B- vectors to take maximums of components.
Returns
minimum vector.

Definition at line 151 of file vec4.h.

151{ return vec4(math::Max(A.X, B.X), math::Max(A.Y, B.Y), math::Max(A.Z, B.Z), math::Max(A.W, B.W)); }
vec4()=default
T Max(T Num1, T Num2)
Definition: math_common.h:61

◆ Min()

template<typename T >
static vec4 scl::math::vec4< T >::Min ( const vec4< T > &  A,
const vec4< T > &  B 
)
inlinestatic
  • Vector with compund of minimums of specified vectors components.
Parameters
A,B- vectors to take minimums of components.
Returns
minimum vector.

Definition at line 143 of file vec4.h.

143{ return vec4(math::Min(A.X, B.X), math::Min(A.Y, B.Y), math::Min(A.Z, B.Z), math::Min(A.W, B.W)); }
T Min(T Num1, T Num2)
Definition: math_common.h:49

◆ operator T*()

template<typename T >
scl::math::vec4< T >::operator T* ( )
inline
  • Getting pointer to first component of vector operator. Need to pass vector to shader.
Returns
pointer to first component of vector.

Definition at line 399 of file vec4.h.

400 {
401 return &X;
402 }

◆ operator*() [1/2]

template<typename T >
const vec4 scl::math::vec4< T >::operator* ( const vec4< T > &  Other) const
inline
  • Vectors multiplying operator overloading.
Parameters
Other- vector to multiply.
Returns
vector with multiplied coordinates.

Definition at line 289 of file vec4.h.

290 {
291 return vec4(X * Other.X, Y * Other.Y, Z * Other.Z, W * Other.W);
292 }

◆ operator*() [2/2]

template<typename T >
const vec4 scl::math::vec4< T >::operator* ( float  Scalar) const
inline
  • Vectors multiplying operator overloading.
Parameters
Scalar- scalar value to add to all vetcors components
Returns
vector with added coordinates.

Definition at line 315 of file vec4.h.

316 {
317 return vec4(X * Scalar,
318 Y * Scalar,
319 Z * Scalar,
320 W * Scalar);
321 }

◆ operator*=() [1/2]

template<typename T >
const vec4 & scl::math::vec4< T >::operator*= ( const vec4< T > &  Other)
inline
  • Vectors multiplying with assigments operator overlaoding.
Parameters
Other- vector to multiply.
Returns
self reference.

Definition at line 300 of file vec4.h.

301 {
302 X *= Other.X;
303 Y *= Other.Y;
304 Z *= Other.Z;
305 W *= Other.W;
306 return *this;
307 }

◆ operator*=() [2/2]

template<typename T >
const vec4 & scl::math::vec4< T >::operator*= ( float  Scalar)
inline
  • Vectors multiplying with assigments operator overlaoding.
Parameters
Other- vector to add.
Returns
self reference

Definition at line 329 of file vec4.h.

330 {
331 X *= Scalar;
332 Y *= Scalar;
333 Z *= Scalar;
334 W *= Scalar;
335 return *this;
336 }

◆ operator+() [1/2]

template<typename T >
const vec4 scl::math::vec4< T >::operator+ ( const vec4< T > &  Other) const
inline
  • Vectors addition operator overloading.
Parameters
Other- vector to add.
Returns
vector with added coordinates.

Definition at line 182 of file vec4.h.

183 {
184 return vec4(X + Other.X, Y + Other.Y, Z + Other.Z, W + Other.W);
185 }

◆ operator+() [2/2]

template<typename T >
const vec4 scl::math::vec4< T >::operator+ ( float  Scalar) const
inline
  • Vectors addition operator overloading.
Parameters
Scalar- scalar value to add to all vetcors components
Returns
vector with added coordinates.

Definition at line 208 of file vec4.h.

209 {
210 return vec4(X + Scalar, Y + Scalar, Z + Scalar, W + Scalar);
211 }

◆ operator+=() [1/2]

template<typename T >
const vec4 & scl::math::vec4< T >::operator+= ( const vec4< T > &  Other)
inline
  • Vectors addition with assigments operator overlaoding.
Parameters
Other- vector to add.
Returns
self reference

Definition at line 193 of file vec4.h.

194 {
195 X += Other.X;
196 Y += Other.Y;
197 Z += Other.Z;
198 W += Other.W;
199 return *this;
200 }

◆ operator+=() [2/2]

template<typename T >
const vec4 & scl::math::vec4< T >::operator+= ( float  Scalar)
inline
  • Vectors addition with assigments operator overlaoding.
Parameters
Other- vector to add.
Returns
self reference

Definition at line 219 of file vec4.h.

220 {
221 X += Scalar;
222 Y += Scalar;
223 Z += Scalar;
224 W += Scalar;
225 return *this;
226 }

◆ operator-() [1/3]

template<typename T >
const vec4 scl::math::vec4< T >::operator- ( ) const
inline
  • Getting negative vector operation.
Parameters
None.
Returns
negative vector.

Definition at line 171 of file vec4.h.

172 {
173 return vec4(-X, -Y, -Z, -W);
174 }

◆ operator-() [2/3]

template<typename T >
const vec4 scl::math::vec4< T >::operator- ( const vec4< T > &  Other) const
inline
  • Vectors subtraction operator overloading.
Parameters
Other- vector to subtract.
Returns
vector with subtract coordinates.

Definition at line 234 of file vec4.h.

235 {
236 return vec4(X - Other.X, Y - Other.Y, Z - Other.Z, W - Other.W);
237 }

◆ operator-() [3/3]

template<typename T >
const vec4 scl::math::vec4< T >::operator- ( float  Scalar) const
inline
  • Vectors subtraction operator overloading.
Parameters
Scalar- scalar value to add to all vetcors components
Returns
vector with added coordinates.

Definition at line 260 of file vec4.h.

261 {
262 return vec4(X - Scalar,
263 Y - Scalar,
264 Z - Scalar,
265 W - Scalar);
266 }

◆ operator-=() [1/2]

template<typename T >
const vec4 & scl::math::vec4< T >::operator-= ( const vec4< T > &  Other)
inline
  • Vectors subtraction with assigments operator overlaoding.
Parameters
Other- vector to subtract.
Returns
self reference.

Definition at line 245 of file vec4.h.

246 {
247 X -= Other.X;
248 Y -= Other.Y;
249 Z -= Other.Z;
250 W -= Other.W;
251 return *this;
252 }

◆ operator-=() [2/2]

template<typename T >
const vec4 & scl::math::vec4< T >::operator-= ( float  Scalar)
inline
  • Vectors subtraction with assigments operator overlaoding.
Parameters
Other- vector to add.
Returns
self reference

Definition at line 274 of file vec4.h.

275 {
276 X -= Scalar;
277 Y -= Scalar;
278 Z -= Scalar;
279 W -= Scalar;
280 return *this;
281 }

◆ operator/() [1/2]

template<typename T >
const vec4 scl::math::vec4< T >::operator/ ( const vec4< T > &  Other) const
inline
  • Vectors dividing operator overloading.
Parameters
Other- vector to devide.
Returns
vector with devided coordinates.

Definition at line 344 of file vec4.h.

345 {
346 return vec4(X / Other.X, Y / Other.Y, Z / Other.Z, W / Other.W);
347 }

◆ operator/() [2/2]

template<typename T >
const vec4 scl::math::vec4< T >::operator/ ( float  Scalar) const
inline
  • Vectors dividing operator overloading.
Parameters
Scalar- scalar value to add to all vetcors components
Returns
vector with added coordinates.

Definition at line 370 of file vec4.h.

371 {
372 return vec4(X / Scalar,
373 Y / Scalar,
374 Z / Scalar,
375 W / Scalar);
376 }

◆ operator/=() [1/2]

template<typename T >
const vec4 & scl::math::vec4< T >::operator/= ( const vec4< T > &  Other)
inline
  • Vectors dividing with assigments operator overlaoding.
Parameters
Other- vector to devide.
Returns
self reference.

Definition at line 355 of file vec4.h.

356 {
357 X /= Other.X;
358 Y /= Other.Y;
359 Z /= Other.Z;
360 W /= Other.W;
361 return *this;
362 }

◆ operator/=() [2/2]

template<typename T >
const vec4 & scl::math::vec4< T >::operator/= ( float  Scalar)
inline
  • Vectors dividing with assigments operator overlaoding.
Parameters
Other- vector to add.
Returns
self reference

Definition at line 384 of file vec4.h.

385 {
386 X /= Scalar;
387 Y /= Scalar;
388 Z /= Scalar;
389 W /= Scalar;
390 return *this;
391 }

◆ operator=()

template<typename T >
vec4 & scl::math::vec4< T >::operator= ( const vec4< T > &  Other)
inline
  • Vector assigments operator overloading.
Parameters
Other- vector to copy from.
Returns
self reference.

Definition at line 107 of file vec4.h.

108 {
109 if (this != &Other)
110 {
111 X = Other.X;
112 Y = Other.Y;
113 Z = Other.Z;
114 W = Other.W;
115 }
116 return *this;
117 }

◆ operator==()

template<typename T >
bool scl::math::vec4< T >::operator== ( const vec4< T > &  Other)
inline

Operators overloading.

  • Vector compare function.
Parameters
Other- vector to compare with.
Returns
is vectors equal flag.

Definition at line 160 of file vec4.h.

161 {
162 return X == Other.X && Y == Other.Y && Z == Other.Z && W == Other.W;
163 }

◆ operator[]() [1/2]

template<typename T >
T & scl::math::vec4< T >::operator[] ( int  Index)
inline
  • Getting coordinate operator overloading.
Parameters
Index- coordinate index.
Returns
vector cartesian coordinate.

Definition at line 410 of file vec4.h.

411 {
412 switch (Index)
413 {
414 case 0: return X;
415 case 1: return Y;
416 case 2: return Z;
417
418 default:
419 case 3: return Z;
420 }
421 }

◆ operator[]() [2/2]

template<typename T >
T scl::math::vec4< T >::operator[] ( int  Index) const
inline
  • Getting coordinate operator overloading.
Parameters
Index- coordinate index.
Returns
vector cartesian coordinate.

Definition at line 429 of file vec4.h.

430 {
431 switch (Index)
432 {
433 case 0: return X;
434 case 1: return Y;
435 case 2: return Z;
436
437 default:
438 case 3: return W;
439 }
440 }

◆ Rnd()

template<typename T >
static vec4 scl::math::vec4< T >::Rnd ( Min = 0,
Max = 1 
)
inlinestatic
  • Vector with all components set to random value in range [Min;Max] creation function.
Parameters
min- lower bound of random number.
Max- upper bound of random number.
Returns
random number in range [Min; Max].

Definition at line 135 of file vec4.h.

135{ return vec4(::scl::math::Rnd(Min, Max)); }
static vec4 Max(const vec4 &A, const vec4 &B)
Definition: vec4.h:151
static vec4 Min(const vec4 &A, const vec4 &B)
Definition: vec4.h:143
T Rnd(T Min=0, T Max=1)
Definition: math_common.h:116

◆ SetW()

template<typename T >
T scl::math::vec4< T >::SetW ( W)
inline

W vector component setter function.

Definition at line 40 of file vec4.h.

40{ this->W = W; }

◆ SetX()

template<typename T >
T scl::math::vec4< T >::SetX ( X)
inline

Public coordinates setters and getters. On coordinate change vector's length calculation state set to false.

X vector component setter function.

Definition at line 34 of file vec4.h.

34{ this->X = X; }

◆ SetY()

template<typename T >
T scl::math::vec4< T >::SetY ( Y)
inline

Y vector component setter function.

Definition at line 36 of file vec4.h.

36{ this->Y = Y; }

◆ SetZ()

template<typename T >
T scl::math::vec4< T >::SetZ ( Z)
inline

Z vector component setter function.

Definition at line 38 of file vec4.h.

38{ this->Z = Z; }

◆ Zero()

template<typename T >
static vec4 scl::math::vec4< T >::Zero ( )
inlinestatic

Common vectors creation functinos.

  • Vector with all components set to 0 creation function.
Parameters
None.
Returns
zero vector.

Definition at line 126 of file vec4.h.

126{ return vec4(0); }

Member Data Documentation

◆ W

template<typename T >
T scl::math::vec4< T >::W { 0 }

Definition at line 29 of file vec4.h.

◆ X

template<typename T >
T scl::math::vec4< T >::X { 0 }

Vector data.

Cartesian coordinates.

Definition at line 29 of file vec4.h.

◆ Y

template<typename T >
T scl::math::vec4< T >::Y { 0 }

Definition at line 29 of file vec4.h.

◆ Z

template<typename T >
T scl::math::vec4< T >::Z { 0 }

Definition at line 29 of file vec4.h.


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