Vec2< T > Class Template Reference
Detailed Description
template<typename T>
class cy::Vec2< T >
class cy::Vec2< T >
2D vector class
#include <cyVector.h>
Public Member Functions | |
Constructors | |
| Vec2 (T _x, T _y) | |
| Vec2 (T v) | |
| Vec2 (Vec3< T > const &p) | |
| Vec2 (Vec4< T > const &p) | |
| Vec2 (T const *v) | |
| template<typename S > | |
| Vec2 (Vec2< S > const &p) | |
| template<typename S > | |
| Vec2 (Vec3< S > const &p) | |
| template<typename S > | |
| Vec2 (Vec4< S > const &p) | |
| template<int N> | |
| Vec2 (Vec< T, N > const &p) | |
| template<int N, typename S > | |
| Vec2 (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) |
| Sets the coordinates using the given values. | |
| void | Normalize () |
| Normalizes the vector, such that its length becomes 1. | |
General methods | |
| Vec2 | 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. | |
| Vec2 | Sqrt () const |
| Returns the square root of the vector. | |
| Vec2 | Abs () const |
| Returns a vector containing the absolute values of all components. | |
| Vec2 | SortAsc () const |
| Returns a vector with components sorted in ascending order. | |
| Vec2 | SortDesc () const |
| Returns a vector with components sorted in descending order. | |
| Vec2 | GetPerpendicular () const |
| Returns a perpendicular vector (rotated by 90 degrees in counter clockwise direction). | |
| template<typename V > | |
| V | Mix (V const v[2]) const |
| Returns the weighted sum of two values, using the components of the vector as weights. | |
| template<typename V > | |
| V | Mix (V const &a, V const &b) const |
| Returns the weighted sum of two values, using the components of the vector as weights. | |
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 | |
| Vec2 | operator- () const |
Binary operators | |
| Vec2 | operator+ (Vec2 const &p) const |
| Vec2 | operator- (Vec2 const &p) const |
| Vec2 | operator* (Vec2 const &p) const |
| Vec2 | operator/ (Vec2 const &p) const |
| Vec2 | operator+ (T const v) const |
| Vec2 | operator- (T const v) const |
| Vec2 | operator* (T const v) const |
| Vec2 | operator/ (T const v) const |
Assignment operators | |
| Vec2 const & | operator+= (Vec2 const &p) |
| Vec2 const & | operator-= (Vec2 const &p) |
| Vec2 const & | operator*= (Vec2 const &p) |
| Vec2 const & | operator/= (Vec2 const &p) |
| Vec2 const & | operator+= (T const v) |
| Vec2 const & | operator-= (T const v) |
| Vec2 const & | operator*= (T const v) |
| Vec2 const & | operator/= (T const v) |
Test operators | |
| bool | operator== (Vec2 const &p) const |
| bool | operator!= (Vec2 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 | |
| T | Cross (Vec2 const &p) const |
| Cross product. | |
| T | operator^ (Vec2 const &p) const |
| Cross product operator. | |
| T | Dot (Vec2 const &p) const |
| Dot product. | |
| T | operator% (Vec2 const &p) const |
| Dot product operator. | |
Swizzling Methods | |
| Vec2< T > | XX () const |
| Vec2< T > | XY () const |
| Vec2< T > | YX () const |
| Vec2< T > | YY () const |
Public Attributes | |
Components of the vector | |
| T | x |
| T | y |
Friends | |
| Vec2 | operator- (T v, Vec2 const &p) |
| Subtraction from a constant. | |
| Vec2 | operator+ (T v, Vec2 const &p) |
| Addition with a constant. | |
| Vec2 | operator* (T v, Vec2 const &p) |
| Multiplication with a constant. | |