ASL
|
A Vec3_ represents a vector in 3D space.
It is a template Vec3_<T>
and has two predefined specializations Vec3
(float) and Vec3d
(double)
This class allows operating with vectors as with primitive types via operators. It can be used together with class Matrix4 to transform vectors in space.
There are operators for dot product (*
), cross product (^
) and multiplication by a scalar (*
).
#include <Vec3.h>
Public Member Functions | |
Vec2_< T > | xy () const |
Returns the x and y components as a Vec2. | |
Vec3_< T > | zyx () const |
Returns this vector with components reversed (z,y,x) | |
Vec2_< T > | h2c () const |
Returns the cartesian coordinates vector corresponding to this homogenous coordinates. | |
Vec3_ | normalized () const |
Returns a normalized version of this vector. | |
T | length () const |
Returns the length of the vector. | |
T | length2 () const |
Returns the length of the vector squared. | |
T | operator! () const |
Returns the length of the vector. | |
T | angle (const Vec3_ &b) const |
Returns the angle between this vector and b | |
Vec3_ | operator+ (const Vec3_ &b) const |
Returns this plus b | |
Vec3_ | operator- (const Vec3_ &b) const |
Returns this minus b | |
Vec3_ | operator^ (const Vec3_ &b) const |
Returns the cross product of this vector and b | |
T | operator* (const Vec3_ &b) const |
Returns the dot product of this vector and b | |
Vec3_ | operator* (T r) const |
Returns this vector multiplied by scalar r | |
Vec3_ | operator/ (T r) const |
Returns this vector divided by scalar r | |
Vec3_ | operator% (const Vec3_ &b) const |
Returns a vector that is a component-wise product of this vector and b | |
bool | operator== (const Vec3_ &b) const |
Checks if this vector is equal to b | |
bool | operator!= (const Vec3_ &b) const |
Checks if this vector is not equal to b | |
void | operator+= (const Vec3_ &b) |
Adds vector b to this vector. | |
void | operator-= (const Vec3_ &b) |
Subtracts vector b from this vector. | |
void | operator*= (T r) |
Multiplies this vector by scalar r | |
void | operator/= (T r) |
Divides this vector by scalar r | |
void | operator%= (const Vec3_ &b) |
Multiplies this vector by another, component-wise. | |
Vec3_ | operator- () const |
Returns this vector negated. | |
bool | isNull (T tol=(T) 0.000001) const |
Returns true if this vector's length is less than a given threshold (almost zero) | |
bool | isParallelToVector (const Vec3_ &v2, T tol=(T) 0.000001) |
Returns true if this vector is nearly parallel to vector v2 with a given tolerance. | |
Public Attributes | |
T | x |
The x, y, z components. | |
Friends | |
Vec3_ | operator* (T r, const Vec3_ &b) |
Returns this vector multiplied by scalar r | |