Files Class List
Vec3< T > Class Template Reference

Detailed Description

template<typename T>
class cy::Vec3< T >

3D vector class

#include <cyVector.h>

Public Member Functions

Constructors
 Vec3 ()
 
 Vec3 (T _x, T _y, T _z)
 
 Vec3 (T v)
 
 Vec3 (Vec2< T > const &p, T _z=0)
 
 Vec3 (Vec4< T > const &p)
 
 Vec3 (T const *v)
 
template<typename S >
 Vec3 (Vec3< S > const &p)
 
template<typename S >
 Vec3 (Vec2< S > const &p, T _z=0)
 
template<typename S >
 Vec3 (Vec4< S > const &p)
 
template<int N>
 Vec3 (Vec< T, N > const &p)
 
template<int N, typename S >
 Vec3 (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)
 Sets the coordinates using the given values.
 
void Set (Vec2< T > const &p, T _z)
 Sets the coordinates using the given values.
 
void Normalize ()
 Normalizes the vector, such that its length becomes 1.
 
General methods
Vec3 GetNormalized () const
 Returns a normalized copy of the vector.
 
LengthSquared () const
 Returns the square of the length. Effectively, this is the dot product of the vector with itself.
 
Length () const
 Returns the length of the vector.
 
Sum () const
 Returns the sum of its components.
 
bool IsZero () const
 Returns true if all components are exactly zero.
 
Min () const
 Returns the minimum component of the vector.
 
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.
 
Vec3 Sqrt () const
 Returns the square root of the vector.
 
Vec3 Abs () const
 Returns a vector containing the absolute values of all components.
 
Vec3 SortAsc () const
 Returns a vector with components sorted in ascending order.
 
Vec3 SortDesc () const
 Returns a vector with components sorted in descending order.
 
Vec3 GetPerpendicular () const
 Returns a perpendicular vector.
 
void GetOrthonormals (Vec3 &v0, Vec3 &v1) const
 < Returns two orthogonal vectors to this vector, forming an orthonormal basis
 
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
Vec3 operator- () const
 
Binary operators
Vec3 operator+ (Vec3 const &p) const
 
Vec3 operator- (Vec3 const &p) const
 
Vec3 operator* (Vec3 const &p) const
 
Vec3 operator/ (Vec3 const &p) const
 
Vec3 operator+ (T const v) const
 
Vec3 operator- (T const v) const
 
Vec3 operator* (T const v) const
 
Vec3 operator/ (T const v) const
 
Assignment operators
Vec3 const & operator+= (Vec3 const &p)
 
Vec3 const & operator-= (Vec3 const &p)
 
Vec3 const & operator*= (Vec3 const &p)
 
Vec3 const & operator/= (Vec3 const &p)
 
Vec3 const & operator+= (T const v)
 
Vec3 const & operator-= (T const v)
 
Vec3 const & operator*= (T const v)
 
Vec3 const & operator/= (T const v)
 
Test operators
bool operator== (Vec3 const &p) const
 
bool operator!= (Vec3 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
 
Cross product and dot product
Vec3 Cross (Vec3 const &p) const
 Cross product.
 
Vec3 operator^ (Vec3 const &p) const
 Cross product.
 
Dot (Vec3 const &p) const
 Dot product.
 
operator% (Vec3 const &p) const
 Dot product.
 
Swizzling Methods
Vec2< T > XX () const
 
Vec2< T > XY () const
 
Vec2< T > XZ () const
 
Vec2< T > YX () const
 
Vec2< T > YY () const
 
Vec2< T > YZ () const
 
Vec2< T > ZX () const
 
Vec2< T > ZY () const
 
Vec2< T > ZZ () const
 
Vec3< T > XXX () const
 
Vec3< T > XXY () const
 
Vec3< T > XXZ () const
 
Vec3< T > XYX () const
 
Vec3< T > XYY () const
 
Vec3< T > XYZ () const
 
Vec3< T > XZX () const
 
Vec3< T > XZY () const
 
Vec3< T > XZZ () const
 
Vec3< T > YXX () const
 
Vec3< T > YXY () const
 
Vec3< T > YXZ () const
 
Vec3< T > YYX () const
 
Vec3< T > YYY () const
 
Vec3< T > YYZ () const
 
Vec3< T > YZX () const
 
Vec3< T > YZY () const
 
Vec3< T > YZZ () const
 
Vec3< T > ZXX () const
 
Vec3< T > ZXY () const
 
Vec3< T > ZXZ () const
 
Vec3< T > ZYX () const
 
Vec3< T > ZYY () const
 
Vec3< T > ZYZ () const
 
Vec3< T > ZZX () const
 
Vec3< T > ZZY () const
 
Vec3< T > ZZZ () const
 

Public Attributes

Components of the vector
x
 
y
 
z
 

Friends

Vec3 operator- (T v, Vec3 const &p)
 Subtraction from a constant.
 
Vec3 operator+ (T v, Vec3 const &p)
 Addition with a constant.
 
Vec3 operator* (T v, Vec3 const &p)
 Multiplication with a constant.