#include <LinAlg/Vec2.h>
Public Types | |
| typedef Vec2< T > | self_type |
| This type. | |
| typedef T | value_type |
| The underlying m_data type. | |
| typedef T * | iterator |
| An iterator. | |
| typedef const T * | const_iterator |
| A constant iterator. | |
| enum | { num_dims = 2 } |
| The number of dimensions. | |
| enum | { num_elements = 2 } |
| The number of elements. | |
Public Member Functions | |
| Vec2 () | |
| Create an uninitialized vector. | |
| Vec2 (const T v0, const T v1) | |
| Create a vector from arguments. | |
| template<typename Other> | Vec2 (const Vec2< Other > &v) |
| Copy a vector of another type. | |
| Vec2 & | operator= (const Vec2 &v) |
| Assign another vector to this one. | |
| const T & | operator() (const unsigned i) const |
| Access an element read-only. | |
| T & | operator() (const unsigned i) |
| Access an element read-write. | |
| const T * | data () const |
| Get a read-only pointer to the first element. | |
| T * | data () |
| Get a read-write pointer to the first element. | |
| const_iterator | begin () const |
| Get a read-only iterator to the first element. | |
| iterator | begin () |
| Get a read-write pointer to the first element. | |
| const_iterator | end () const |
| Get a read-only iterator to past the last element. | |
| iterator | end () |
| Get a read-write iterator to past the last element. | |
| unsigned | size () const |
| Return the number of elements in the vector. | |
| void | limit (const std::pair< T, T > &l) |
| Limit each element of the vector to the range [l.first, l.second]. | |
| void | limit (const T lower, const T upper) |
| Limit each element of the vector to the range [lower, upper]. | |
| void | limit (const Vec2 &lower, const Vec2 &upper) |
| Limit element i of the vector to the range [lower[i], upper[i]]. | |
| T | sum () const |
| Return the sum of all the elements. | |
| T | prod () const |
| Return the product of all the elements. | |
| T | length () const |
| Return the geometric length of the vector. | |
| T | lengthSqr () const |
| Return the geometric length squared of the vector. | |
| bool | equal (const Vec2 &v, const T eps) const |
| Is this vector the same as another, within epsilon? | |
| Vec2 & | operator+= (const Vec2 &v) |
| Add another vector to this one. | |
| Vec2 & | operator-= (const Vec2 &v) |
| Subtract another vector from this one. | |
| template<typename Scalar> Vec2 & | operator *= (const Scalar d) |
| Multiply this vector by a scalar. | |
| template<typename Scalar> Vec2 & | operator/= (const Scalar d) |
| Divide this vector by a scalar. Does not check for zero. | |
Static Public Member Functions | |
| const Vec2 & | zero () |
| Return the zero vector. | |
| const Vec2 | unit (const unsigned index) |
| Return the unit vector with v(i) == 0 and v(index) == 1. | |
| std::string | description () |
| Return a description like "2D float vector", useful for debugging and messages. | |
Protected Attributes | |
| T | m_data [2] |
| The element storage. | |
Friends | |
| Vec2 | operator- (const Vec2 &u) |
| Negate a vector. | |
| Vec2 | operator+ (const Vec2 &u, const Vec2 &v) |
| Add two vectors. | |
| Vec2 | operator- (const Vec2 &u, const Vec2 &v) |
| Subtract two vectors. | |
| Vec2 | operator * (const Vec2< T > &u, const T s) |
| Right-multiply a vector by a scalar. | |
| Vec2 | operator * (const T s, const Vec2< T > &u) |
| Left-multiply a vector by a scalar. | |
| Vec2 | operator/ (const Vec2< T > &u, const T s) |
| Right-divide a vector by a scalar. | |
| bool | operator== (const Vec2 &u, const Vec2 &v) |
| Exact equality -- use with caution on floating-point base types. | |
| bool | operator!= (const Vec2 &u, const Vec2 &v) |
| Exact inequality -- use with caution on floating-point base types. | |
| T | inner (const Vec2 &u, const Vec2 &v) |
The inner (dot) product of u and v. | |
| Vec2 | proj (const Vec2 &u, const Vec2 &v) |
Return the projection of u onto v. | |
| Vec2 | min (const Vec2 &u, const Vec2 &v) |
| Per-element minimum. | |
| Vec2 | max (const Vec2 &u, const Vec2 &v) |
| Per-element maximum. | |
| Vec2 | normalized (const Vec2 &u) |
Unit vector in direction of u. Does not check for u.length() == 0. | |
|
||||||||||||||
|
Copy a vector of another type.
|
© 2005-2008 Adrian Secord.