4D vector More...

#include <vec4.h>

Public Types

typedef Type datatype
 

Public Member Functions

 Vec4 ()
 
 Vec4 (const Type &p1, const Type &p2, const Type &p3, const Type &p4)
 
 Vec4 (const Type &p1, const Type &p2, const Vec2< Type > &copy34)
 
 Vec4 (const Type &scalar)
 
 Vec4 (const Type *array_xyzw)
 
 Vec4 (const Vec2< Type > &copy, const Type &p3, const Type &p4)
 
 Vec4 (const Vec2< Type > &copy, const Vec2< Type > &copy34)
 
 Vec4 (const Vec3< Type > &copy, const Type &p4)
 
template<typename OtherType, typename std::enable_if_t< std::is_integral< Type >::value &&!std::is_integral< OtherType >::value, int > = 0>
 Vec4 (const Vec4< OtherType > &copy)
 
template<typename OtherType, typename std::enable_if_t<!std::is_integral< Type >::value||std::is_integral< OtherType >::value, int > = 0>
 Vec4 (const Vec4< OtherType > &copy)
 
 Vec4 (const Vec4< Type > &copy)=default
 
Angle angle3 (const Vec4< Type > &vector) const
 Calculate the angle between this vector and an other vector (not taking into account the w ordinate).
 
Vec4< Type > & cross3 (const Vec4< Type > &vector)
 Calculate the cross product between this vector and an other vector (not taking into account the w ordinate).
 
Type distance3 (const Vec4< Type > &vector) const
 Calculate the distance between this vector and an other vector (not taking into account the w ordinate).
 
Type distance4 (const Vec4< Type > &vector) const
 Calculate the distance between this vector and an other vector (taking into account the w ordinate).
 
Type dot3 (const Vec4< Type > &vector) const
 Dot products this vector with an other vector (not taking into account the w ordinate).
 
Type dot4 (const Vec4< Type > &vector) const
 Dot products this vector with an other vector (taking into account the w ordinate).
 
bool is_equal (const Vec4< Type > &other, Type epsilon) const
 Returns true if equal within the bounds of an epsilon.
 
Type length3 () const
 Returns the length (magnitude) of this vector (not taking into account the w ordinate).
 
double length3 () const
 
float length3 () const
 
Type length4 () const
 Returns the length (magnitude) of this vector (taking into account the w ordinate).
 
double length4 () const
 
float length4 () const
 
Vec4< Type > & normalize3 ()
 Normalizes this vector (not taking into account the w ordinate)
 
Vec4< Type > & normalize4 ()
 Normalizes this vector (taking into account the w ordinate)
 
bool operator!= (const Vec4< Type > &vector) const
 != operator.
 
void operator*= (const Vec4< Type > &vector)
 *= operator.
 
void operator*= (Type value)
 *= operator.
 
void operator+= (const Vec4< Type > &vector)
 += operator.
 
void operator+= (Type value)
 += operator.
 
Vec4< Type > operator- () const
 
  • operator.

 
void operator-= (const Vec4< Type > &vector)
 -= operator.
 
void operator-= (Type value)
 -= operator.
 
void operator/= (const Vec4< Type > &vector)
 /= operator.
 
void operator/= (Type value)
 /= operator.
 
bool operator< (const Vec4< Type > &vector) const
 < operator.
 
Vec4< Type > & operator= (const Vec4< Type > &vector)=default
 = operator.
 
bool operator== (const Vec4< Type > &vector) const
 == operator.
 
Vec4< Type > & rotate3 (const Angle &angle, const Vec4< Type > &axis)
 Rotate this vector around an axis. Same as glRotate[f|d](angle, a);.
 
Vec4< Type > & round ()
 Rounds all components on this vector.
 
void set_xy (const Vec2< Type > &new_v)
 
void set_zw (const Vec2< Type > &new_v)
 

Static Public Member Functions

static Vec4< Type > cross3 (const Vec4< Type > &vector1, const Vec4< Type > &vector2)
 Calculate the cross product between two vectors (not taking into account the w ordinate).
 
static Type dot3 (const Vec4< Type > &vector1, const Vec4< Type > &vector2)
 Dot products between two vectors (not taking into account the w ordinate).
 
static Type dot4 (const Vec4< Type > &vector1, const Vec4< Type > &vector2)
 Dot products between two vectors (taking into account the w ordinate).
 
static bool is_equal (const Vec4< Type > &first, const Vec4< Type > &second, Type epsilon)
 Returns true if equal within the bounds of an epsilon.
 
static Vec4< Type > normalize3 (const Vec4< Type > &vector)
 Normalizes a vector (not taking into account the w ordinate)
 
static Vec4< Type > normalize4 (const Vec4< Type > &vector)
 Normalizes a vector (taking into account the w ordinate)
 
static Vec4< Type > rotate3 (const Vec4< Type > &vector, const Angle &angle, const Vec4< Type > &axis)
 Rotate a vector around an axis. Same as glRotate[f|d](angle, a);.
 
static Vec4< Type > round (const Vec4< Type > &vector)
 Rounds all components on a vector.
 

Public Attributes

union { 
 
   Type   a 
 
   Type   v 
 
   Type   w 
 
};  
 
union { 
 
   Type   g 
 
   Type   t 
 
   Type   y 
 
};  
 
union { 
 
   Type   r 
 
   Type   s 
 
   Type   x 
 
};  
 
union { 
 
   Type   b 
 
   Type   u 
 
   Type   z 
 
};  
 

Detailed Description

template<typename Type>
class clan::Vec4< Type >

4D vector

These vector templates are defined for:
char (Vec4c), unsigned char (Vec4uc), short (Vec4s),
unsigned short (Vec4us), int (Vec4i), unsigned int (Vec4ui), float (Vec4f), double (Vec4d)

Member Typedef Documentation

◆ datatype

template<typename Type>
typedef Type clan::Vec4< Type >::datatype

Constructor & Destructor Documentation

◆ Vec4() [1/11]

template<typename Type>
clan::Vec4< Type >::Vec4 ( )
inline

◆ Vec4() [2/11]

template<typename Type>
clan::Vec4< Type >::Vec4 ( const Type & scalar)
inlineexplicit

◆ Vec4() [3/11]

template<typename Type>
clan::Vec4< Type >::Vec4 ( const Vec2< Type > & copy,
const Type & p3,
const Type & p4 )
inlineexplicit

◆ Vec4() [4/11]

template<typename Type>
clan::Vec4< Type >::Vec4 ( const Vec2< Type > & copy,
const Vec2< Type > & copy34 )
inlineexplicit

◆ Vec4() [5/11]

template<typename Type>
clan::Vec4< Type >::Vec4 ( const Vec3< Type > & copy,
const Type & p4 )
inlineexplicit

◆ Vec4() [6/11]

template<typename Type>
clan::Vec4< Type >::Vec4 ( const Type & p1,
const Type & p2,
const Type & p3,
const Type & p4 )
inlineexplicit

◆ Vec4() [7/11]

template<typename Type>
clan::Vec4< Type >::Vec4 ( const Type & p1,
const Type & p2,
const Vec2< Type > & copy34 )
inlineexplicit

◆ Vec4() [8/11]

template<typename Type>
clan::Vec4< Type >::Vec4 ( const Type * array_xyzw)
inlineexplicit

◆ Vec4() [9/11]

template<typename Type>
clan::Vec4< Type >::Vec4 ( const Vec4< Type > & copy)
default

◆ Vec4() [10/11]

template<typename Type>
template<typename OtherType, typename std::enable_if_t< std::is_integral< Type >::value &&!std::is_integral< OtherType >::value, int > = 0>
clan::Vec4< Type >::Vec4 ( const Vec4< OtherType > & copy)
inline

◆ Vec4() [11/11]

template<typename Type>
template<typename OtherType, typename std::enable_if_t<!std::is_integral< Type >::value||std::is_integral< OtherType >::value, int > = 0>
clan::Vec4< Type >::Vec4 ( const Vec4< OtherType > & copy)
inline

Member Function Documentation

◆ angle3()

template<typename Type>
Angle clan::Vec4< Type >::angle3 ( const Vec4< Type > & vector) const

Calculate the angle between this vector and an other vector (not taking into account the w ordinate).

Parameters
vector= Second vector used to calculate angle.
Returns
The angle between the two vectors.

◆ cross3() [1/2]

template<typename Type>
Vec4< Type > & clan::Vec4< Type >::cross3 ( const Vec4< Type > & vector)

Calculate the cross product between this vector and an other vector (not taking into account the w ordinate).

Operates in the native datatype

Parameters
vectorSecond vector used to perform the calculation.
Returns
reference to this object

◆ cross3() [2/2]

template<typename Type>
static Vec4< Type > clan::Vec4< Type >::cross3 ( const Vec4< Type > & vector1,
const Vec4< Type > & vector2 )
static

Calculate the cross product between two vectors (not taking into account the w ordinate).

\vector1 = The first vector \vector2 = The second vector

Returns
= Cross product

◆ distance3()

template<typename Type>
Type clan::Vec4< Type >::distance3 ( const Vec4< Type > & vector) const

Calculate the distance between this vector and an other vector (not taking into account the w ordinate).

Parameters
vector= Second vector used to calculate distance.
Returns
The distance between the two vectors.

◆ distance4()

template<typename Type>
Type clan::Vec4< Type >::distance4 ( const Vec4< Type > & vector) const

Calculate the distance between this vector and an other vector (taking into account the w ordinate).

Parameters
vector= Second vector used to calculate distance.
Returns
The distance between the two vectors.

◆ dot3() [1/2]

template<typename Type>
Type clan::Vec4< Type >::dot3 ( const Vec4< Type > & vector) const
inline

Dot products this vector with an other vector (not taking into account the w ordinate).

Operates in the native datatype

Parameters
vectorSecond vector used for the dot product.
Returns
The resulting dot product of the two vectors.

◆ dot3() [2/2]

template<typename Type>
static Type clan::Vec4< Type >::dot3 ( const Vec4< Type > & vector1,
const Vec4< Type > & vector2 )
inlinestatic

Dot products between two vectors (not taking into account the w ordinate).

Operates in the native datatype

Parameters
vector1First vector used for the dot product.
vector2Second vector used for the dot product.
Returns
The resulting dot product of the two vectors.

◆ dot4() [1/2]

template<typename Type>
Type clan::Vec4< Type >::dot4 ( const Vec4< Type > & vector) const
inline

Dot products this vector with an other vector (taking into account the w ordinate).

Operates in the native datatype

Parameters
vectorSecond vector used for the dot product.
Returns
The resulting dot product of the two vectors.

◆ dot4() [2/2]

template<typename Type>
static Type clan::Vec4< Type >::dot4 ( const Vec4< Type > & vector1,
const Vec4< Type > & vector2 )
inlinestatic

Dot products between two vectors (taking into account the w ordinate).

Operates in the native datatype

Parameters
vector1First vector used for the dot product.
vector2Second vector used for the dot product.
Returns
The resulting dot product of the two vectors.

◆ is_equal() [1/2]

template<typename Type>
static bool clan::Vec4< Type >::is_equal ( const Vec4< Type > & first,
const Vec4< Type > & second,
Type epsilon )
inlinestatic

Returns true if equal within the bounds of an epsilon.

Parameters
first= Value A
second= Value B
epsilon= The epsilon (eg FLT_EPSILON/2, DBL_EPSILON/2)

Referenced by clan::Vec4< unsigned char >::is_equal().

◆ is_equal() [2/2]

template<typename Type>
bool clan::Vec4< Type >::is_equal ( const Vec4< Type > & other,
Type epsilon ) const
inline

Returns true if equal within the bounds of an epsilon.

Parameters
other= Other value
epsilon= The epsilon (eg FLT_EPSILON/2, DBL_EPSILON/2)

◆ length3() [1/2]

double clan::Vec4< double >::length3 ( ) const
inline

◆ length3() [2/2]

float clan::Vec4< float >::length3 ( ) const
inline

◆ length4() [1/2]

double clan::Vec4< double >::length4 ( ) const
inline

◆ length4() [2/2]

float clan::Vec4< float >::length4 ( ) const
inline

◆ normalize3() [1/2]

template<typename Type>
Vec4< Type > & clan::Vec4< Type >::normalize3 ( )

Normalizes this vector (not taking into account the w ordinate)

Operates in the native datatype

Returns
reference to this object

◆ normalize3() [2/2]

template<typename Type>
static Vec4< Type > clan::Vec4< Type >::normalize3 ( const Vec4< Type > & vector)
static

Normalizes a vector (not taking into account the w ordinate)

Operates in the native datatype

Parameters
vector= The vector to use
Returns
the normalized vector

◆ normalize4() [1/2]

template<typename Type>
Vec4< Type > & clan::Vec4< Type >::normalize4 ( )

Normalizes this vector (taking into account the w ordinate)

Operates in the native datatype

Returns
reference to this object

◆ normalize4() [2/2]

template<typename Type>
static Vec4< Type > clan::Vec4< Type >::normalize4 ( const Vec4< Type > & vector)
static

Normalizes a vector (taking into account the w ordinate)

Operates in the native datatype

Parameters
vector= The vector to use
Returns
the normalized vector

◆ operator!=()

template<typename Type>
bool clan::Vec4< Type >::operator!= ( const Vec4< Type > & vector) const
inline

!= operator.

◆ operator*=() [1/2]

template<typename Type>
void clan::Vec4< Type >::operator*= ( const Vec4< Type > & vector)
inline

*= operator.

◆ operator*=() [2/2]

template<typename Type>
void clan::Vec4< Type >::operator*= ( Type value)
inline

*= operator.

◆ operator+=() [1/2]

template<typename Type>
void clan::Vec4< Type >::operator+= ( const Vec4< Type > & vector)
inline

+= operator.

◆ operator+=() [2/2]

template<typename Type>
void clan::Vec4< Type >::operator+= ( Type value)
inline

+= operator.

◆ operator-()

template<typename Type>
Vec4< Type > clan::Vec4< Type >::operator- ( ) const
inline

  • operator.

◆ operator-=() [1/2]

template<typename Type>
void clan::Vec4< Type >::operator-= ( const Vec4< Type > & vector)
inline

-= operator.

◆ operator-=() [2/2]

template<typename Type>
void clan::Vec4< Type >::operator-= ( Type value)
inline

-= operator.

◆ operator/=() [1/2]

template<typename Type>
void clan::Vec4< Type >::operator/= ( const Vec4< Type > & vector)
inline

/= operator.

◆ operator/=() [2/2]

template<typename Type>
void clan::Vec4< Type >::operator/= ( Type value)
inline

/= operator.

◆ operator<()

template<typename Type>
bool clan::Vec4< Type >::operator< ( const Vec4< Type > & vector) const
inline

< operator.

◆ operator=()

template<typename Type>
Vec4< Type > & clan::Vec4< Type >::operator= ( const Vec4< Type > & vector)
default

= operator.

◆ operator==()

template<typename Type>
bool clan::Vec4< Type >::operator== ( const Vec4< Type > & vector) const
inline

== operator.

◆ rotate3() [1/2]

template<typename Type>
Vec4< Type > & clan::Vec4< Type >::rotate3 ( const Angle & angle,
const Vec4< Type > & axis )

Rotate this vector around an axis. Same as glRotate[f|d](angle, a);.

Not taking into account the w ordinate
The w ordinate is not modified

Parameters
angleAngle to rotate
axisRotation axis.
Returns
reference to this object

◆ rotate3() [2/2]

template<typename Type>
static Vec4< Type > clan::Vec4< Type >::rotate3 ( const Vec4< Type > & vector,
const Angle & angle,
const Vec4< Type > & axis )
static

Rotate a vector around an axis. Same as glRotate[f|d](angle, a);.

Not taking into account the w ordinate
The w ordinate is not modified

Parameters
vector= The vector to use
angleAngle to rotate
axisRotation axis.
Returns
The rotated vector

◆ round() [1/2]

template<typename Type>
Vec4< Type > & clan::Vec4< Type >::round ( )

Rounds all components on this vector.

Includes the w ordinate
Uses Asymmetric Arithmetic Rounding

Returns
reference to this object

◆ round() [2/2]

template<typename Type>
static Vec4< Type > clan::Vec4< Type >::round ( const Vec4< Type > & vector)
static

Rounds all components on a vector.

Includes the w ordinate
Uses Asymmetric Arithmetic Rounding

Parameters
vector= The vector to use
Returns
The rounded vector

◆ set_xy()

template<typename Type>
void clan::Vec4< Type >::set_xy ( const Vec2< Type > & new_v)
inline

◆ set_zw()

template<typename Type>
void clan::Vec4< Type >::set_zw ( const Vec2< Type > & new_v)
inline

Member Data Documentation

◆ [union]

union { ... } clan::Vec4< Type >

◆ [union]

union { ... } clan::Vec4< Type >

◆ [union]

union { ... } clan::Vec4< Type >

◆ [union]

union { ... } clan::Vec4< Type >

◆ a

template<typename Type>
Type clan::Vec4< Type >::a

◆ b

template<typename Type>
Type clan::Vec4< Type >::b

◆ g

template<typename Type>
Type clan::Vec4< Type >::g

◆ r

template<typename Type>
Type clan::Vec4< Type >::r

◆ s

template<typename Type>
Type clan::Vec4< Type >::s

◆ t

template<typename Type>
Type clan::Vec4< Type >::t

◆ u

template<typename Type>
Type clan::Vec4< Type >::u

◆ v

template<typename Type>
Type clan::Vec4< Type >::v

◆ w

◆ x

◆ y

◆ z


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