All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Nimble::Vector3T< T > Class Template Reference

Three-dimensional vector class for 3D mathematics. More...

#include <Nimble/Vector3.hpp>

Public Types

enum  { ELEMENTS = 3 }
 
typedef T type
 Data type of the vector.
 

Public Member Functions

template<typename S >
Nimble::Vector3T< S > cast () const
 Cast the vector to another type.
 
Vector3Tclamp (T low, T high)
 Clamps all components to the range [low, high].
 
Vector3TclampUnit (void)
 Clamps components to range [0,1].
 
void clear (void)
 Fills the vector with zeroes.
 
T * data ()
 Returns a pointer to the first element.
 
const T * data () const
 Returns a pointer to the first element.
 
Vector3Tdescale (const Vector3T &v)
 Divide component-wise.
 
T & get (size_t i)
 Multiply component-wise.
 
const T & get (size_t i) const
 Multiply component-wise.
 
bool isOne (void) const
 Check if all components are one.
 
bool isZero (void) const
 Check if all components are zero.
 
double length (void) const
 Returns the length of the vector.
 
double lengthSqr (void) const
 Returns the squared length of the vector.
 
Vector3Tmake (const Vector2T< T > &v, T cz)
 Sets the vector to given values.
 
Vector3Tmake (T cx, T cy, T cz)
 Sets the vector to given values.
 
Vector3Tmake (T xyz)
 Fills the vector with given value.
 
maximum () const
 Returns the largest component.
 
minimum () const
 Returns the smallest component.
 
Vector3Tnegate (void)
 Returns the negation of the vector.
 
Vector3Tnormalize (double len=1.0)
 Normalizes the vector to the given length. More...
 
Vector3T normalized (double len=1.0) const
 Get a vector normalized to given length. More...
 
bool operator!= (const Vector3T &src) const
 Compares if two vectors differ.
 
Vector3T operator* (T s) const
 Multiplies a vector with a scalar.
 
Vector3Toperator*= (T s)
 Multiplies a vector with a scalar.
 
Vector3T operator+ (const Vector3T &v) const
 Adds two vectors.
 
Vector3Toperator+= (const Vector3T &v)
 Adds two vectors.
 
Vector3T operator- (const Vector3T &v) const
 Subtract two vectors.
 
Vector3T operator- () const
 Returns the negation of the vector.
 
Vector3Toperator-= (const Vector3T &v)
 Subtract two vectors.
 
Vector3T operator/ (T s) const
 Divides a vector with a scalar.
 
Vector3Toperator/= (T s)
 Divides a vector with a scalar.
 
bool operator== (const Vector3T &src) const
 Compares if two vectors are equal.
 
const T & operator[] (size_t i) const
 Returns the ith component.
 
T & operator[] (size_t i)
 Multiply component-wise.
 
Vector3Tscale (const Vector3T &v)
 Multiply component-wise.
 
void set (size_t i, T v)
 Sets the ith component.
 
Vector3T shuffle (int i1, int i2, int i3) const
 Returns a vector with components reordered.
 
sum () const
 Sum of all components.
 
Vector2T< T > vector2 () const
 Returns a copy of the first two components as a Vector2. More...
 
Vector2T< T > vector2 (int i0, int i1) const
 Makes a new Nimble::Vector2f of two freely selected components of vector3. More...
 
 Vector3T (T cx, T cy, T cz)
 Constructs a vector initializing it to given values.
 
 Vector3T (const Vector2T< T > &v, T az)
 Constructs a vector using a 2d vector and a scalar component.
 

Static Public Member Functions

static Vector3T< T > null ()
 Zero vector. More...
 

Public Attributes

x
 x-component of the vector
 
y
 y-component of the vector
 
z
 z-component of the vector
 

Detailed Description

template<typename T>
class Nimble::Vector3T< T >

Three-dimensional vector class for 3D mathematics.

Member Function Documentation

template<typename T>
Vector3T& Nimble::Vector3T< T >::normalize ( double  len = 1.0)
inline

Normalizes the vector to the given length.

Parameters
lenlength to normalize to
Returns
reference to this
template<typename T>
Vector3T Nimble::Vector3T< T >::normalized ( double  len = 1.0) const
inline

Get a vector normalized to given length.

Parameters
lenlength to normalize to
Returns
normalized vector
template<typename T>
static Vector3T<T> Nimble::Vector3T< T >::null ( )
inlinestatic

Zero vector.

Returns
a zero vector
template<typename T>
Vector2T<T> Nimble::Vector3T< T >::vector2 ( ) const
inline

Returns a copy of the first two components as a Vector2.

Returns
New vector2
template<typename T>
Vector2T<T> Nimble::Vector3T< T >::vector2 ( int  i0,
int  i1 
) const
inline

Makes a new Nimble::Vector2f of two freely selected components of vector3.

Parameters
i0Index of the first component, vec2.x = vec3[i0], 0..2
i1Index of the second component, vec2.y = vec3[i1], 0..2
Returns
New vector2