- Main Page
- Modules
- Classes
- Files
- Related Pages

- Class List
- Class Hierarchy
- Class Members

# Vector4< T > Class Template Reference

`#include <vmath.h>`

List of all members.

## Public Member Functions
| Vector4 ()
| Vector4 (T nx, T ny, T nz, T nw)
| Vector4 (const Vector4< T > &src)
template<class FromT>
| Vector4 (const Vector4< FromT > &src)
Vector4< T > | operator= (const Vector4< T > &rhs)
template<class FromT>
Vector4< T > | operator= (const Vector4< FromT > &rhs)
T & | operator[] (int n)
Vector4< T > | operator+ (const Vector4< T > &rhs) const
Vector4< T > | operator- (const Vector4< T > &rhs) const
Vector4< T > | operator * (const Vector4< T > rhs) const
Vector4< T > | operator/ (const Vector4< T > &rhs) const
Vector4< T > & | operator+= (const Vector4< T > &rhs)
Vector4< T > & | operator-= (const Vector4< T > &rhs)
Vector4< T > & | operator *= (const Vector4< T > &rhs)
Vector4< T > & | operator/= (const Vector4< T > &rhs)
bool | operator== (const Vector4< T > &rhs) const
bool | operator!= (const Vector4< T > &rhs) const
Vector4< T > | operator+ (T rhs) const
Vector4< T > | operator- (T rhs) const
Vector4< T > | operator * (T rhs) const
Vector4< T > | operator/ (T rhs) const
Vector4< T > & | operator+= (T rhs)
Vector4< T > & | operator-= (T rhs)
Vector4< T > & | operator *= (T rhs)
Vector4< T > & | operator/= (T rhs)
T | length () const
void | normalize ()
void | invert ()
Vector4< T > | getPerpendicular ()
T | lengthSq () const
Vector4< T > | lerp (T fact, const Vector4< T > &r) const
| operator T * ()
| operator const T * () const
## Public Attributes
union {
T r
T x
}; |
union {
T g
T y
}; |
union {
T b
T z
}; |
union {
T a
T w
}; |
## Friends
std::ostream & | operator<< (std::ostream &lhs, const Vector4< T > &rhs)

## Detailed Description

### template<class T>
class Vector4< T >

Class for four dimensional vector.

## Constructor & Destructor Documentation

template<class T>

Vector4< T >::Vector4 | ( |  | ) | `[inline]`

Creates and sets to (0,0,0,0)

template<class T>

Vector4< T >::Vector4 | ( | T | nx,
|  | T | ny,
|  | T | nz,
|  | T | nw |
| ) |  |  | `[inline]`

Creates and sets to (x,y,z,z)

Parameters:

  | nx | intial x-coordinate value (R)
  | ny | intial y-coordinate value (G)
  | nz | intial z-coordinate value (B)
  | nw | intial w-coordinate value (Aplha)

template<class T>

Vector4< T >::Vector4 | ( | const Vector4< T > & | src | ) | `[inline]`

Copy constructor.

Parameters:

  | src | Source of data for new created Vector4 instance.

template<class T>
template<class FromT>

Vector4< T >::Vector4 | ( | const Vector4< FromT > & | src | ) | `[inline]`

Copy casting constructor.

Parameters:

  | src | Source of data for new created Vector4 instance.

## Member Function Documentation

template<class T>

Vector4<T> Vector4< T >::getPerpendicular | ( |  | ) | `[inline]`

Gets vector perpendicular to itself

template<class T>

void Vector4< T >::invert | ( |  | ) | `[inline]`

Invert vector

template<class T>

T Vector4< T >::length | ( |  | ) | const`[inline]`

Get lenght of vector.

Returns:
  lenght of vector

template<class T>

T Vector4< T >::lengthSq | ( |  | ) | const`[inline]`

Return square of length.

Returns:
  lenght ^ 2

Note:
  This method is faster then length(). For comparsion of length of two vector can be used just this value, instead of computionaly more expensive length() method.

template<class T>

Vector4<T> Vector4< T >::lerp | ( | T | fact,
|  | const Vector4< T > & | r |
| ) |  |  | const`[inline]`

Linear interpolation of two vectors

Parameters:

  | fact | Factor of interpolation. For translation from positon of this vector to vector r, values of factor goes from 0.0 to 1.0.
  | r | Second Vector for interpolation

Note:
  Hovewer values of fact parameter are reasonable only in interval [0.0 , 1.0], you can pass also values outside of this interval and you can get result (extrapolation?)

template<class T>

void Vector4< T >::normalize | ( |  | ) | `[inline]`

Normalize vector

template<class T>

Vector4<T> Vector4< T >::operator * | ( | T | rhs | ) | const`[inline]`

Multiplication operator

Parameters:

  | rhs | Right hand side argument of binary operator.

template<class T>

Vector4<T> Vector4< T >::operator * | ( | const Vector4< T > | rhs | ) | const`[inline]`

Multiplication operator

Parameters:

  | rhs | Right hand side argument of binary operator.

template<class T>

Vector4<T>& Vector4< T >::operator *= | ( | T | rhs | ) | `[inline]`

Multiplication operator

Parameters:

  | rhs | Right hand side argument of binary operator.

template<class T>

Vector4<T>& Vector4< T >::operator *= | ( | const Vector4< T > & | rhs | ) | `[inline]`

Multiplication operator

Parameters:

  | rhs | Right hand side argument of binary operator.

template<class T>

Vector4< T >::operator const T * | ( |  | ) | const`[inline]`

Conversion to pointer operator

Returns:
  Constant Pointer to internaly stored (in managment of class Vector4<T>) used for passing Vector4<T> values to gl*4[fd] functions.

template<class T>

Vector4< T >::operator T * | ( |  | ) | `[inline]`

Conversion to pointer operator

Returns:
  Pointer to internaly stored (in managment of class Vector4<T>) used for passing Vector4<T> values to gl*4[fd] functions.

template<class T>

bool Vector4< T >::operator!= | ( | const Vector4< T > & | rhs | ) | const`[inline]`

Inequality test operator

Parameters:

  | rhs | Right hand side argument of binary operator.

Returns:
  not (lhs == rhs) :-P

template<class T>

Vector4<T> Vector4< T >::operator+ | ( | T | rhs | ) | const`[inline]`

Addition operator

Parameters:

  | rhs | Right hand side argument of binary operator.

template<class T>

Vector4<T> Vector4< T >::operator+ | ( | const Vector4< T > & | rhs | ) | const`[inline]`

Addition operator

Parameters:

  | rhs | Right hand side argument of binary operator.

template<class T>

Vector4<T>& Vector4< T >::operator+= | ( | T | rhs | ) | `[inline]`

Addition operator

Parameters:

  | rhs | Right hand side argument of binary operator.

template<class T>

Vector4<T>& Vector4< T >::operator+= | ( | const Vector4< T > & | rhs | ) | `[inline]`

Addition operator

Parameters:

  | rhs | Right hand side argument of binary operator.

template<class T>

Vector4<T> Vector4< T >::operator- | ( | T | rhs | ) | const`[inline]`

Substraction operator

Parameters:

  | rhs | Right hand side argument of binary operator.

template<class T>

Vector4<T> Vector4< T >::operator- | ( | const Vector4< T > & | rhs | ) | const`[inline]`

Substraction operator

Parameters:

  | rhs | Right hand side argument of binary operator.

template<class T>

Vector4<T>& Vector4< T >::operator-= | ( | T | rhs | ) | `[inline]`

Substraction operator

Parameters:

  | rhs | Right hand side argument of binary operator.

template<class T>

Vector4<T>& Vector4< T >::operator-= | ( | const Vector4< T > & | rhs | ) | `[inline]`

Substraction operator

Parameters:

  | rhs | Right hand side argument of binary operator.

template<class T>

Vector4<T> Vector4< T >::operator/ | ( | T | rhs | ) | const`[inline]`

Division operator

Parameters:

  | rhs | Right hand side argument of binary operator.

template<class T>

Vector4<T> Vector4< T >::operator/ | ( | const Vector4< T > & | rhs | ) | const`[inline]`

Division operator

Parameters:

  | rhs | Right hand side argument of binary operator.

template<class T>

Vector4<T>& Vector4< T >::operator/= | ( | T | rhs | ) | `[inline]`

Division operator

Parameters:

  | rhs | Right hand side argument of binary operator.

template<class T>

Vector4<T>& Vector4< T >::operator/= | ( | const Vector4< T > & | rhs | ) | `[inline]`

Division operator

Parameters:

  | rhs | Right hand side argument of binary operator.

template<class T>
template<class FromT>

Vector4<T> Vector4< T >::operator= | ( | const Vector4< FromT > & | rhs | ) | `[inline]`

Copy casting operator

Parameters:

  | rhs | Right hand side argument of binary operator.

template<class T>

Vector4<T> Vector4< T >::operator= | ( | const Vector4< T > & | rhs | ) | `[inline]`

Copy operator

Parameters:

  | rhs | Right hand side argument of binary operator.

template<class T>

bool Vector4< T >::operator== | ( | const Vector4< T > & | rhs | ) | const`[inline]`

Equality test operator

Parameters:

  | rhs | Right hand side argument of binary operator.

Note:
  Test of equality is based of threshold epsilon value. To be two values equal, must satisfy this condition | lws.x - rhs.y | < epsilon, same for y-coordinate, z-coordinate, and w-coordinate.

template<class T>

T& Vector4< T >::operator[] | ( | int | n | ) | `[inline]`

Array access operator

Parameters:

  | n | Array index

Returns:
  For n = 0, reference to x coordinate, n = 1 reference to y coordinate, n = 2 reference to z, else reference to w coordinate.

## Friends And Related Function Documentation

template<class T>

std::ostream& operator<< | ( | std::ostream & | lhs,
|  | const Vector4< T > & | rhs |
| ) |  |  | `[friend]`

Output to stream operator

Parameters:

  | lhs | Left hand side argument of operator (commonly ostream instance).
  | rhs | Right hand side argument of operator.

Returns:
  Left hand side argument - the ostream object passed to operator.

## Member Data Documentation

union { ... }

union { ... }

union { ... }

union { ... }

template<class T>

T Vector4< T >::a

Fourth element of vector, alias for A-coordinate. For color notation. This represnt aplha chanell

template<class T>

T Vector4< T >::b

Third element of vector, alias for B-coordinate. For color notation.

template<class T>

T Vector4< T >::g

Second element of vector, alias for G-coordinate. For color notation.

template<class T>

T Vector4< T >::r

First element of vector, alias for X-coordinate.

template<class T>

T Vector4< T >::w

First element of vector, alias for W-coordinate.

Note:
  For vectors (such as normals) should be set to 0.0 For vertices should be set to 1.0

template<class T>

T Vector4< T >::x

template<class T>

T Vector4< T >::y

Second element of vector, alias for Y-coordinate.

template<class T>

T Vector4< T >::z

Third element of vector, alias for Z-coordinate.

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

- src/vectorMath/vmath.h