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

#include <vec3.h>

Public Member Functions

SetX (T X)
 
SetY (T Y)
 
SetZ (T Z)
 
GetX () const
 
GetY () const
 
GetZ () const
 
 vec3 ()=default
 
 vec3 (T A)
 
 vec3 (T X, T Y, T Z)
 
 vec3 (vec2< T > V, T Z)
 
 vec3 (T X, vec2< T > V)
 
 vec3 (const vec3 &Other)
 
vec3operator= (const vec3 &Other)
 
Length2 () const
 
Length () const
 
Distacnce (const vec3 &Other) const
 
vec3 Normalized () const
 
vec3Normalize ()
 
Dot (const vec3 &Other) const
 
vec3 Cross (const vec3 &Other) const
 
bool operator== (const vec3 &Other) const
 
const vec3 operator- () const
 
const vec3 operator+ (const vec3 &Other) const
 
const vec3operator+= (const vec3 &Other)
 
const vec3 operator+ (float Scalar) const
 
const vec3operator+= (float Scalar)
 
const vec3 operator- (const vec3 &Other) const
 
const vec3operator-= (const vec3 &Other)
 
const vec3 operator- (float Scalar) const
 
const vec3operator-= (float Scalar)
 
const vec3 operator* (const vec3 &Other) const
 
const vec3operator*= (const vec3 &Other)
 
const vec3 operator* (float Scalar) const
 
const vec3operator*= (float Scalar)
 
const vec3 operator/ (const vec3 &Other) const
 
const vec3operator/= (const vec3 &Other)
 
const vec3 operator/ (float Scalar) const
 
const vec3operator/= (float Scalar)
 
 operator T* ()
 
T & operator[] (int Index)
 
operator[] (int Index) const
 

Static Public Member Functions

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

Public Attributes

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

Friends

template<typename T >
class matr4
 

Detailed Description

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

Definition at line 25 of file vec3.h.

Constructor & Destructor Documentation

◆ vec3() [1/6]

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

Vector construcotrs.

Default construcotr. All coodinates would ve set to zero.

◆ vec3() [2/6]

template<typename T >
scl::math::vec3< T >::vec3 ( 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 59 of file vec3.h.

59: X(A), Y(A), Z(A) {}

◆ vec3() [3/6]

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

Definition at line 66 of file vec3.h.

66: X(X), Y(Y), Z(Z) {}

◆ vec3() [4/6]

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

Definition at line 74 of file vec3.h.

74: X(V.X), Y(V.Y), Z(Z) {}

◆ vec3() [5/6]

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

Definition at line 82 of file vec3.h.

82: X(X), Y(V.X), Z(V.Z) {}

◆ vec3() [6/6]

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

Definition at line 89 of file vec3.h.

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

Member Function Documentation

◆ Cross()

template<typename T >
vec3 scl::math::vec3< T >::Cross ( const vec3< T > &  Other) const
inline
  • Vectors cross product function.
Parameters
Other- vector to multiply
Returns
cross product resulting rector.

Definition at line 224 of file vec3.h.

225 {
226 return vec3(Y * Other.Z - Other.Y * Z,
227 Z * Other.X - Other.Z * X,
228 X * Other.Y - Other.X * Y);
229 }
vec3()=default

◆ Distacnce()

template<typename T >
T scl::math::vec3< T >::Distacnce ( const vec3< T > &  Other) const
inline
  • Distance between two vectors getting function.
Parameters
Other- vector to get distance to.
Returns
distance between vectors.

Definition at line 179 of file vec3.h.

180 {
181 return (*this - Other).Length();
182 }

◆ Dot()

template<typename T >
T scl::math::vec3< T >::Dot ( const vec3< T > &  Other) const
inline
  • Vectors dot product function.
Parameters
Other- vector to multiply
Returns
value of vectors dot product.

Definition at line 213 of file vec3.h.

214 {
215 return X * Other.X + Y * Other.Y + Z * Other.Z;
216 }

◆ GetX()

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

X vector component getter function.

Definition at line 43 of file vec3.h.

43{ return X; }

◆ GetY()

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

Y vector component getter function.

Definition at line 45 of file vec3.h.

45{ return Y; }

◆ GetZ()

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

Z vector component getter function.

Definition at line 47 of file vec3.h.

47{ return Z; }

◆ Length()

template<typename T >
T scl::math::vec3< T >::Length ( ) const
inline
  • Vector length getting function.
Parameters
None.
Returns
length of vector.

Definition at line 168 of file vec3.h.

169 {
170 return sqrt(Length2());
171 }
T Length2() const
Definition: vec3.h:157

◆ Length2()

template<typename T >
T scl::math::vec3< T >::Length2 ( ) const
inline

Vector methods.

  • Vector squared length getting function.
Parameters
None.
Returns
length of vector.

Definition at line 157 of file vec3.h.

158 {
159 return X * X + Y * Y + Z * Z;
160 }

◆ Max()

template<typename T >
static vec3 scl::math::vec3< T >::Max ( const vec3< T > &  A,
const vec3< 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 148 of file vec3.h.

148{ return vec3(math::Max(A.X, B.X), math::Max(A.Y, B.Y), math::Max(A.Z, B.Z)); }
T Max(T Num1, T Num2)
Definition: math_common.h:61

◆ Min()

template<typename T >
static vec3 scl::math::vec3< T >::Min ( const vec3< T > &  A,
const vec3< 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 140 of file vec3.h.

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

◆ Normalize()

template<typename T >
vec3 & scl::math::vec3< T >::Normalize ( )
inline
  • Normalize vector function.
Parameters
None.
Returns
normalized vector.

Definition at line 201 of file vec3.h.

202 {
203 *this /= Length();
204 return *this;
205 }
T Length() const
Definition: vec3.h:168

◆ Normalized()

template<typename T >
vec3 scl::math::vec3< T >::Normalized ( ) const
inline
  • Normalized vector getting function.
Parameters
None.
Returns
normalized vector.

Definition at line 190 of file vec3.h.

191 {
192 return *this / Length();
193 }

◆ operator T*()

template<typename T >
scl::math::vec3< 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 468 of file vec3.h.

469 {
470 return &X;
471 }

◆ operator*() [1/2]

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

Definition at line 364 of file vec3.h.

365 {
366 return vec3(X * Other.X, Y * Other.Y, Z * Other.Z);
367 }

◆ operator*() [2/2]

template<typename T >
const vec3 scl::math::vec3< 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 389 of file vec3.h.

390 {
391 return vec3(X * Scalar,
392 Y * Scalar,
393 Z * Scalar);
394 }

◆ operator*=() [1/2]

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

Definition at line 375 of file vec3.h.

376 {
377 X *= Other.X;
378 Y *= Other.Y;
379 Z *= Other.Z;
380 return *this;
381 }

◆ operator*=() [2/2]

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

Definition at line 402 of file vec3.h.

403 {
404 X *= Scalar;
405 Y *= Scalar;
406 Z *= Scalar;
407 return *this;
408 }

◆ operator+() [1/2]

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

Definition at line 260 of file vec3.h.

261 {
262 return vec3(X + Other.X, Y + Other.Y, Z + Other.Z);
263 }

◆ operator+() [2/2]

template<typename T >
const vec3 scl::math::vec3< 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 285 of file vec3.h.

286 {
287 return vec3(X + Scalar,
288 Y + Scalar,
289 Z + Scalar);
290 }

◆ operator+=() [1/2]

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

Definition at line 271 of file vec3.h.

272 {
273 X += Other.X;
274 Y += Other.Y;
275 Z += Other.Z;
276 return *this;
277 }

◆ operator+=() [2/2]

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

Definition at line 298 of file vec3.h.

299 {
300 X += Scalar;
301 Y += Scalar;
302 Z += Scalar;
303 return *this;
304 }

◆ operator-() [1/3]

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

Definition at line 249 of file vec3.h.

250 {
251 return vec3(-X, -Y, -Z);
252 }

◆ operator-() [2/3]

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

Definition at line 312 of file vec3.h.

313 {
314 return vec3(X - Other.X, Y - Other.Y, Z - Other.Z);
315 }

◆ operator-() [3/3]

template<typename T >
const vec3 scl::math::vec3< 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 337 of file vec3.h.

338 {
339 return vec3(X - Scalar,
340 Y - Scalar,
341 Z - Scalar);
342 }

◆ operator-=() [1/2]

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

Definition at line 323 of file vec3.h.

324 {
325 X -= Other.X;
326 Y -= Other.Y;
327 Z -= Other.Z;
328 return *this;
329 }

◆ operator-=() [2/2]

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

Definition at line 350 of file vec3.h.

351 {
352 X -= Scalar;
353 Y -= Scalar;
354 Z -= Scalar;
355 return *this;
356 }

◆ operator/() [1/2]

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

Definition at line 416 of file vec3.h.

417 {
418 return vec3(X / Other.X, Y / Other.Y, Z / Other.Z);
419 }

◆ operator/() [2/2]

template<typename T >
const vec3 scl::math::vec3< 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 441 of file vec3.h.

442 {
443 return vec3(X / Scalar,
444 Y / Scalar,
445 Z / Scalar);
446 }

◆ operator/=() [1/2]

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

Definition at line 427 of file vec3.h.

428 {
429 X /= Other.X;
430 Y /= Other.Y;
431 Z /= Other.Z;
432 return *this;
433 }

◆ operator/=() [2/2]

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

Definition at line 454 of file vec3.h.

455 {
456 X /= Scalar;
457 Y /= Scalar;
458 Z /= Scalar;
459 return *this;
460 }

◆ operator=()

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

Definition at line 105 of file vec3.h.

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

◆ operator==()

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

Operators overloading.

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

Definition at line 238 of file vec3.h.

239 {
240 return X == Other.X && Y == Other.Y && Z == Other.Z;
241 }

◆ operator[]() [1/2]

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

Definition at line 479 of file vec3.h.

480 {
481 switch (Index)
482 {
483 case 0: return X;
484 case 1: return Y;
485 default:
486 case 2: return Z;
487 }
488 }

◆ operator[]() [2/2]

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

Definition at line 496 of file vec3.h.

497 {
498 switch (Index)
499 {
500 case 0: return X;
501 case 1: return Y;
502 default:
503 case 2: return Z;
504 }
505 }

◆ Rnd()

template<typename T >
static vec3 scl::math::vec3< 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 132 of file vec3.h.

132{ return vec3(Rnd(Min, Max)); }
static vec3 Max(const vec3 &A, const vec3 &B)
Definition: vec3.h:148
static vec3 Rnd(T Min=0, T Max=1)
Definition: vec3.h:132
static vec3 Min(const vec3 &A, const vec3 &B)
Definition: vec3.h:140

◆ SetX()

template<typename T >
T scl::math::vec3< 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 37 of file vec3.h.

37{ this->X = X; }

◆ SetY()

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

Y vector component setter function.

Definition at line 39 of file vec3.h.

39{ this->Y = Y; }

◆ SetZ()

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

Z vector component setter function.

Definition at line 41 of file vec3.h.

41{ this->Z = Z; }

◆ Zero()

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

Common vectors creation functinos.

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

Definition at line 123 of file vec3.h.

123{ return vec3(0); }

Friends And Related Function Documentation

◆ matr4

template<typename T >
template<typename T >
friend class matr4
friend

4x4 Matrix friend class forward declaration.

Definition at line 28 of file vec3.h.

Member Data Documentation

◆ X

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

Vector data.

Cartesian coordinates.

Definition at line 32 of file vec3.h.

◆ Y

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

Definition at line 32 of file vec3.h.

◆ Z

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

Definition at line 32 of file vec3.h.


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