Files Class List
Vec< T, N > Class Template Reference

Detailed Description

template<typename T, int N>
class cy::Vec< T, N >

A general class for N-dimensional vectors.

#include <cyVector.h>

Public Member Functions

Constructors
 Vec () CY_CLASS_FUNCTION_DEFAULT explicit Vec(T const *p)
 
 Vec (T v)
 
template<typename S >
 Vec (Vec< S, N > const &p)
 
template<int M>
 Vec (Vec< T, M > const &p)
 
template<typename S , int M>
 Vec (Vec< S, M > const &p)
 
 Vec (Vec2< T > const &p)
 
 Vec (Vec3< T > const &p)
 
 Vec (Vec4< T > const &p)
 
template<typename S >
 Vec (Vec2< S > const &p)
 
template<typename S >
 Vec (Vec3< S > const &p)
 
template<typename S >
 Vec (Vec4< S > const &p)
 
template<typename P >
 Vec (P const &p)
 
Set & Get value methods
void Zero ()
 
void Get (T *p) const
 
void Set (T const *p)
 
void Set (T v)
 
template<int M>
void CopyData (T *p)
 
template<typename S , int M>
void ConvertData (S *p)
 
General methods
void Normalize ()
 
Vec GetNormalized () const
 
LengthSquared () const
 
Length () const
 
Sum () const
 
bool IsZero () const
 
Min () const
 
Max () const
 
int MinID () const
 
int MaxID () const
 
bool IsFinite () const
 
bool IsUnit () const
 
Vec Sqrt () const
 
Vec Abs () const
 
Limit methods
void Clamp (T minLimit, T maxLimit)
 
void ClampMin (T v)
 
void ClampMax (T v)
 
void SetAbs ()
 
Unary operators
Vec operator- () const
 
Binary operators
Vec operator+ (Vec const &p) const
 
Vec operator- (Vec const &p) const
 
Vec operator* (Vec const &p) const
 
Vec operator/ (Vec const &p) const
 
Vec operator+ (T const v) const
 
Vec operator- (T const v) const
 
Vec operator* (T const v) const
 
Vec operator/ (T const v) const
 
Assignment operators
Vec const & operator+= (Vec const &p)
 
Vec const & operator-= (Vec const &p)
 
Vec const & operator*= (Vec const &p)
 
Vec const & operator/= (Vec const &p)
 
Vec const & operator+= (T const v)
 
Vec const & operator-= (T const v)
 
Vec const & operator*= (T const v)
 
Vec const & operator/= (T const v)
 
Test operators
bool operator== (Vec const &p) const
 
bool operator!= (Vec const &p) const
 
Access operators
T & operator[] (int i)
 
operator[] (int i) const
 
T & Element (int i)
 
T const & Element (int i) const
 
T * Elements ()
 
T const * Elements () const
 
Dot product
Dot (Vec const &p) const
 
operator% (Vec const &p) const
 

Public Attributes

Components of the vector
elem [N]
 

Friends

Vec operator+ (T v, Vec const &p)
 
Vec operator- (T v, Vec const &p)
 
Vec operator* (T v, Vec const &p)
 

Member Function Documentation

§ Zero()

void Zero ( )

Sets the coordinates as zero.

§ Get()

void Get ( T *  p) const

Puts the coordinate values into the array.

§ Set() [1/2]

void Set ( T const *  p)

Sets the coordinates using the values in the given array.

§ Set() [2/2]

void Set ( v)

Sets all coordinates using the given value.

§ CopyData()

void CopyData ( T *  p)

Sets the coordinates as zero.

§ ConvertData()

void ConvertData ( S *  p)

Sets the coordinates as zero.

§ Normalize()

void Normalize ( )

Normalizes the vector, such that its length becomes 1.

§ GetNormalized()

Vec GetNormalized ( ) const

Returns a normalized copy of the vector.

§ LengthSquared()

T LengthSquared ( ) const

Returns the square of the length. Effectively, this is the dot product of the vector with itself.

§ Length()

T Length ( ) const

Returns the length of the vector.

§ Sum()

T Sum ( ) const

Returns the sum of its components.

§ IsZero()

bool IsZero ( ) const

Returns true if all components are exactly zero.

§ Min()

T Min ( ) const

Returns the minimum component of the vector.

§ Max()

T Max ( ) const

Returns the maximum component of the vector.

§ MinID()

int MinID ( ) const

Returns the index of the minimum component of the vector.

§ MaxID()

int MaxID ( ) const

Returns the index of the maximum component of the vector.

§ IsFinite()

bool IsFinite ( ) const

Returns true if all components are finite real numbers.

§ IsUnit()

bool IsUnit ( ) const

Returns true if the length of the vector is close to 1.

§ Sqrt()

Vec Sqrt ( ) const

Returns the square root of the vector.

§ Abs()

Vec Abs ( ) const

Returns a vector containing the absolute values of all components.

§ Clamp()

void Clamp ( minLimit,
maxLimit 
)

Ensures that all components of the vector are within the given limits.

§ ClampMin()

void ClampMin ( v)

Ensures that all components of the vector are greater than or equal to the given limit.

§ ClampMax()

void ClampMax ( v)

Ensures that all components of the vector are smaller than or equal to the given limit.

§ SetAbs()

void SetAbs ( )

Converts all negative components to positive values.

§ Dot()

T Dot ( Vec< T, N > const &  p) const

Dot product.

§ operator%()

T operator% ( Vec< T, N > const &  p) const

Dot product operator.

Friends And Related Function Documentation

§ operator+

Vec operator+ ( v,
Vec< T, N > const &  p 
)
friend

Addition with a constant.

§ operator-

Vec operator- ( v,
Vec< T, N > const &  p 
)
friend

Subtraction from a constant.

§ operator*

Vec operator* ( v,
Vec< T, N > const &  p 
)
friend

Multiplication with a constant.