v1.1.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Modules Pages
Public Member Functions | Public Attributes | List of all members
Sifteo::Vector3< T > Struct Template Reference

Generalized three-element cartesian coordinate vector. More...

#include <sifteo/math.h>

Public Member Functions

template<typename R >
Vector3< R > cast () const
 Explicitly cast this vector to another vector type, using default C++ truncation or extension rules.
 
len () const
 Calculate the scalar length (magnitude) of this vector.
 
len2 () const
 Calculate the scalar length (magnitude) of this vector, squared. More...
 
lenManhattan () const
 Calculate the manhattan (city block) distance of this vector.
 
Vector3< T > normalize () const
 Return a normalized version of this vector. More...
 
Vector3< int > round () const
 Round a floating point vector to the nearest integer.
 
void set (T _x, T _y, T _z)
 Modify this vector's value in-place.
 
Vector3< double > toDouble () const
 Explicit cast to double.
 
Vector3< float > toFloat () const
 Explicit cast to float.
 
Vector3< int > toInt () const
 Explicit cast to int.
 
Vector2< T > xy () const
 Extract a 2-vector with only the XY components.
 
Vector2< T > xz () const
 Extract a 2-vector with only the XZ components.
 
Vector2< T > yx () const
 Extract a 2-vector with only the YX components.
 
Vector2< T > yz () const
 Extract a 2-vector with only the YZ components.
 
Vector3< T > zRotate (float angle) const
 Rotate the vector about the Z axis counterclockwise by 'angle' radians.
 
Vector3< T > zRotateI (int angle) const
 Rotate this vector about the Z axis counterclockwise by an integer multiple of 90 degrees. More...
 
Vector2< T > zx () const
 Extract a 2-vector with only the ZX components.
 
Vector2< T > zy () const
 Extract a 2-vector with only the ZY components.
 

Public Attributes

x
 Vector component X.
 
y
 Vector component Y.
 
z
 Vector component Z.
 

Detailed Description

template<typename T>
struct Sifteo::Vector3< T >

Generalized three-element cartesian coordinate vector.

Member Function Documentation

template<typename T>
T Sifteo::Vector3< T >::len2 ( ) const
inline

Calculate the scalar length (magnitude) of this vector, squared.

This avoids the costly square root calculation.

template<typename T>
Vector3<T> Sifteo::Vector3< T >::normalize ( ) const
inline

Return a normalized version of this vector.

The returned vector will have a magnitude of 1.0.

template<typename T>
Vector3<T> Sifteo::Vector3< T >::zRotateI ( int  angle) const
inline

Rotate this vector about the Z axis counterclockwise by an integer multiple of 90 degrees.

The angle must be 0, 1, 2, or 3. If you must pass larger angles, you can use umod(a, 4) to fold them into this range.


The documentation for this struct was generated from the following file: