Vec4< T > Class Template Reference
Detailed Description
template<typename T>
class cy::Vec4< T >
class cy::Vec4< T >
4D vector class
#include <cyVector.h>
Public Member Functions | |
Constructors | |
Vec4 (T _x, T _y, T _z, T _w) | |
Vec4 (T v) | |
Vec4 (Vec2< T > const &p, T _z=0, T _w=1) | |
Vec4 (Vec3< T > const &p, T _w=1) | |
Vec4 (T const *v) | |
template<typename S > | |
Vec4 (Vec2< S > const &p, T _z=0, T _w=1) | |
template<typename S > | |
Vec4 (Vec3< S > const &p, T _w=1) | |
template<typename S > | |
Vec4 (Vec4< S > const &p) | |
template<int N> | |
Vec4 (Vec< T, N > const &p) | |
template<int N, typename S > | |
Vec4 (Vec< S, N > const &p) | |
Set & Get value methods | |
void | Zero () |
Sets the coordinates as zero. | |
void | Get (T *p) const |
Puts the coordinate values into the array. | |
void | Set (T const *p) |
Sets the coordinates using the values in the given array. | |
void | Set (T v) |
Sets all coordinates using the given value. | |
void | Set (T _x, T _y, T _z, T _w=1) |
Sets the coordinates using the given values. | |
void | Set (Vec2< T > const &p, T _z, T _w=1) |
Sets the coordinates using the given values. | |
void | Set (Vec3< T > const &p, T _w=1) |
Sets the coordinates using the given values. | |
void | Normalize () |
Normalizes the vector, such that its length becomes 1. | |
General methods | |
Vec4 | GetNormalized () const |
Returns a normalized copy of the vector. | |
T | LengthSquared () const |
Returns the square of the length. Effectively, this is the dot product of the vector with itself. | |
T | Length () const |
Returns the length of the vector. | |
T | Sum () const |
Returns the sum of its components. | |
bool | IsZero () const |
Returns true if all components are exactly zero. | |
T | Min () const |
Returns the minimum component of the vector. | |
T | Max () const |
Returns the maximum component of the vector. | |
int | MinComp () const |
Returns the index of the minimum component of the vector. | |
int | MaxComp () const |
Returns the index of the maximum component of the vector. | |
bool | IsFinite () const |
Returns true if all components are finite real numbers. | |
bool | IsUnit () const |
Returns true if the length of the vector is close to 1. | |
Vec4 | Sqrt () const |
Returns the square root of the vector. | |
Vec4 | Abs () const |
Returns a vector containing the absolute values of all components. | |
Vec4 | SortAsc () const |
Returns a vector with components sorted in ascending order. | |
Vec4 | SortDesc () const |
Returns a vector with components sorted in descending order. | |
Limit methods | |
void | Clamp (T minLimit, T maxLimit) |
Ensures that all components of the vector are within the given limits. | |
void | ClampMin (T v) |
Ensures that all components of the vector are greater than or equal to the given limit. | |
void | ClampMax (T v) |
Ensures that all components of the vector are smaller than or equal to the given limit. | |
void | SetAbs () |
Converts all negative components to positive values. | |
Unary operators | |
Vec4 | operator- () const |
Binary operators | |
Vec4 | operator+ (Vec4 const &p) const |
Vec4 | operator- (Vec4 const &p) const |
Vec4 | operator* (Vec4 const &p) const |
Vec4 | operator/ (Vec4 const &p) const |
Vec4 | operator+ (T const v) const |
Vec4 | operator- (T const v) const |
Vec4 | operator* (T const v) const |
Vec4 | operator/ (T const v) const |
Assignment operators | |
Vec4 const & | operator+= (Vec4 const &p) |
Vec4 const & | operator-= (Vec4 const &p) |
Vec4 const & | operator*= (Vec4 const &p) |
Vec4 const & | operator/= (Vec4 const &p) |
Vec4 const & | operator+= (T const v) |
Vec4 const & | operator-= (T const v) |
Vec4 const & | operator*= (T const v) |
Vec4 const & | operator/= (T const v) |
Test operators | |
bool | operator== (Vec4 const &p) const |
bool | operator!= (Vec4 const &p) const |
Access operators | |
T & | operator[] (int i) |
T const & | operator[] (int i) const |
T & | Element (int i) |
T const & | Element (int i) const |
T * | Elements () |
T const * | Elements () const |
Dot product | |
T | Dot (Vec4 const &p) const |
Dot product. | |
T | operator% (Vec4 const &p) const |
Dot product. | |
Swizzling Methods | |
Vec2< T > | XX () const |
Vec2< T > | XY () const |
Vec2< T > | XZ () const |
Vec2< T > | XW () const |
Vec2< T > | YX () const |
Vec2< T > | YY () const |
Vec2< T > | YZ () const |
Vec2< T > | YW () const |
Vec2< T > | ZX () const |
Vec2< T > | ZY () const |
Vec2< T > | ZZ () const |
Vec2< T > | ZW () const |
Vec2< T > | WX () const |
Vec2< T > | WY () const |
Vec2< T > | WZ () const |
Vec2< T > | WW () const |
Vec3< T > | XXX () const |
Vec3< T > | XXY () const |
Vec3< T > | XXZ () const |
Vec3< T > | XXW () const |
Vec3< T > | XYX () const |
Vec3< T > | XYY () const |
Vec3< T > | XYZ () const |
Vec3< T > | XYW () const |
Vec3< T > | XZX () const |
Vec3< T > | XZY () const |
Vec3< T > | XZZ () const |
Vec3< T > | XZW () const |
Vec3< T > | XWX () const |
Vec3< T > | XWY () const |
Vec3< T > | XWZ () const |
Vec3< T > | XWW () const |
Vec3< T > | YXX () const |
Vec3< T > | YXY () const |
Vec3< T > | YXZ () const |
Vec3< T > | YXW () const |
Vec3< T > | YYX () const |
Vec3< T > | YYY () const |
Vec3< T > | YYZ () const |
Vec3< T > | YYW () const |
Vec3< T > | YZX () const |
Vec3< T > | YZY () const |
Vec3< T > | YZZ () const |
Vec3< T > | YZW () const |
Vec3< T > | YWX () const |
Vec3< T > | YWY () const |
Vec3< T > | YWZ () const |
Vec3< T > | YWW () const |
Vec3< T > | ZXX () const |
Vec3< T > | ZXY () const |
Vec3< T > | ZXZ () const |
Vec3< T > | ZXW () const |
Vec3< T > | ZYX () const |
Vec3< T > | ZYY () const |
Vec3< T > | ZYZ () const |
Vec3< T > | ZYW () const |
Vec3< T > | ZZX () const |
Vec3< T > | ZZY () const |
Vec3< T > | ZZZ () const |
Vec3< T > | ZZW () const |
Vec3< T > | ZWX () const |
Vec3< T > | ZWY () const |
Vec3< T > | ZWZ () const |
Vec3< T > | ZWW () const |
Vec3< T > | WXX () const |
Vec3< T > | WXY () const |
Vec3< T > | WXZ () const |
Vec3< T > | WXW () const |
Vec3< T > | WYX () const |
Vec3< T > | WYY () const |
Vec3< T > | WYZ () const |
Vec3< T > | WYW () const |
Vec3< T > | WZX () const |
Vec3< T > | WZY () const |
Vec3< T > | WZZ () const |
Vec3< T > | WZW () const |
Vec3< T > | WWX () const |
Vec3< T > | WWY () const |
Vec3< T > | WWZ () const |
Vec3< T > | WWW () const |
Vec3< T > | GetNonHomogeneous () const |
Public Attributes | |
Components of the vector | |
T | x |
T | y |
T | z |
T | w |
Friends | |
Vec4 | operator- (T v, Vec4 const &p) |
Subtraction from a constant. | |
Vec4 | operator+ (T v, Vec4 const &p) |
Addition with a constant. | |
Vec4 | operator* (T v, Vec4 const &p) |
Multiplication with a constant. | |