The Nebula Device 3: Math::vector Class Reference

The Nebula Device 3

Math::vector Class Reference

#include <xna_vector.h>

Inheritance diagram for Math::vector:

Math::float4

Detailed Description

A vector in homogenous space. A point describes a direction and length in 3d space and always has a w component of 0.0.

(C) 2007 Radon Labs GmbH

Public Member Functions

 vector ()
 default constructor
 vector (scalar x, scalar y, scalar z)
 construct from components
 vector (const float4 &rhs)
 construct from float4
 vector (XMVECTOR rhs)
 construct from XMVECTOR
void operator= (const vector &rhs)
 assignment operator
void operator= (XMVECTOR rhs)
 assign XMVECTOR
vector operator- () const
 flip sign
void operator+= (const vector &rhs)
 add vector inplace
void operator-= (const vector &rhs)
 subtract vector inplace
void operator *= (scalar s)
 scale vector inplace
vector operator+ (const vector &rhs) const
 add 2 vectors
vector operator- (const vector &rhs) const
 subtract 2 vectors
vector operator * (scalar s) const
 scale vector
bool operator== (const vector &rhs) const
 equality operator
bool operator!= (const vector &rhs) const
 inequality operator
void set (scalar x, scalar y, scalar z)
 set components
float4 operator- (const float4 &rhs) const
 subtract 2 vectors
void operator+= (const float4 &rhs)
 inplace add
void operator-= (const float4 &rhs)
 inplace sub
void operator *= (const float4 &rhs)
 muliply by a vector component-wise
float4 operator+ (const float4 &rhs) const
 add 2 vectors
bool operator== (const float4 &rhs) const
 equality operator
bool operator!= (const float4 &rhs) const
 inequality operator
void load (const scalar *ptr)
 load content from 16-byte-aligned memory
void loadu (const scalar *ptr)
 load content from unaligned memory
void store (scalar *ptr) const
 write content to 16-byte-aligned memory through the write cache
void storeu (scalar *ptr) const
 write content to unaligned memory through the write cache
void stream (scalar *ptr) const
 stream content to 16-byte-aligned memory circumventing the write-cache
void load_float3 (const void *ptr, float w)
 load 3 floats into x,y,z from unaligned memory
void load_ubyte4n_signed (const void *ptr, float w)
 load from UByte4N packed vector, move range to -1..+1
void set (scalar x, scalar y, scalar z, scalar w)
 set content
void set_x (scalar x)
 set the x component
void set_y (scalar y)
 set the y component
void set_z (scalar z)
 set the z component
void set_w (scalar w)
 set the w component
scalar & x ()
 read/write access to x component
scalar x () const
 read-only access to x component
scalar & y ()
 read/write access to y component
scalar y () const
 read-only access to y component
scalar & z ()
 read/write access to z component
scalar z () const
 read-only access to z component
scalar & w ()
 read/write access to w component
scalar w () const
 read-only access to w component
scalar length () const
 return length of vector
scalar lengthsq () const
 return squared length of vector
float4 abs () const
 return compononent-wise absolute

Static Public Member Functions

static vector nullvec ()
 return the null vector
static vector upvec ()
 return the standard up vector (0, 1, 0)
static float4 reciprocal (const float4 &v)
 return 1.0 / vec
static float4 multiply (const float4 &v0, const float4 &v1)
 component-wise multiplication
static float4 cross3 (const float4 &v0, const float4 &v1)
 return 3-dimensional cross product
static scalar dot3 (const float4 &v0, const float4 &v1)
 return 3d dot product of vectors
static float4 barycentric (const float4 &v0, const float4 &v1, const float4 &v2, scalar f, scalar g)
 return point in barycentric coordinates
static float4 catmullrom (const float4 &v0, const float4 &v1, const float4 &v2, const float4 &v3, scalar s)
 perform Catmull-Rom interpolation
static float4 hermite (const float4 &v1, const float4 &t1, const float4 &v2, const float4 &t2, scalar s)
 perform Hermite spline interpolation
static float4 lerp (const float4 &v0, const float4 &v1, scalar s)
 perform linear interpolation between 2 4d vectors
static float4 maximize (const float4 &v0, const float4 &v1)
 return 4d vector made up of largest components of 2 vectors
static float4 minimize (const float4 &v0, const float4 &v1)
 return 4d vector made up of smallest components of 2 vectors
static float4 normalize (const float4 &v)
 return normalized version of 4d vector
static __declspec (deprecated) float4 transform(__Float4Arg v
 transform 4d vector by matrix44
static float4 reflect (const float4 &normal, const float4 &incident)
 reflect a vector v
static float4 clamp (__Float4Arg Clamp, __Float4Arg vMin, __Float4Arg vMax)
 clamp to min/max vector
static scalar angle (__Float4Arg v0, __Float4Arg v1)
 angle between two vectors
static bool less3_any (const float4 &v0, const float4 &v1)
 return true if any XYZ component is less-then
static bool less3_all (const float4 &v0, const float4 &v1)
 return true if all XYZ components are less-then
static bool lessequal3_any (const float4 &v0, const float4 &v1)
 return true if any XYZ component is less-or-equal
static bool lessequal3_all (const float4 &v0, const float4 &v1)
 return true if all XYZ components are less-or-equal
static bool greater3_any (const float4 &v0, const float4 &v1)
 return true if any XYZ component is greater
static bool greater3_all (const float4 &v0, const float4 &v1)
 return true if all XYZ components are greater
static bool greaterequal3_any (const float4 &v0, const float4 &v1)
 return true if any XYZ component is greater-or-equal
static bool greaterequal3_all (const float4 &v0, const float4 &v1)
 return true if all XYZ components are greater-or-equal
static bool equal3_any (const float4 &v0, const float4 &v1)
 return true if any XYZ component is equal
static bool equal3_all (const float4 &v0, const float4 &v1)
 return true if all XYZ components are equal
static bool nearequal3 (const float4 &v0, const float4 &v1, const float4 &epsilon)
 perform near equal comparison with given epsilon (3 components)
static bool less4_any (const float4 &v0, const float4 &v1)
 return true if any XYZW component is less-then
static bool less4_all (const float4 &v0, const float4 &v1)
 return true if all XYZW components are less-then
static bool lessequal4_any (const float4 &v0, const float4 &v1)
 return true if any XYZW component is less-or-equal
static bool lessequal4_all (const float4 &v0, const float4 &v1)
 return true if all XYZW components are less-or-equal
static bool greater4_any (const float4 &v0, const float4 &v1)
 return true if any XYZW component is greater
static bool greater4_all (const float4 &v0, const float4 &v1)
 return true if all XYZW components are greater
static bool greaterequal4_any (const float4 &v0, const float4 &v1)
 return true if any XYZW component is greater-or-equal
static bool greaterequal4_all (const float4 &v0, const float4 &v1)
 return true if all XYZW components are greater-or-equal
static bool equal4_any (const float4 &v0, const float4 &v1)
 return true if any XYZW component is equal
static bool equal4_all (const float4 &v0, const float4 &v1)
 return true if all XYZW components are equal
static bool nearequal4 (const float4 &v0, const float4 &v1, const float4 &epsilon)
 perform near equal comparison with given epsilon (4 components)
static float unpack_x (XMVECTOR v)
 unpack the first element from a XMVECTOR
static float unpack_y (XMVECTOR v)
 unpack the second element from a XMVECTOR
static float unpack_z (XMVECTOR v)
 unpack the third element from a XMVECTOR
static float unpack_w (XMVECTOR v)
 unpack the fourth element from a XMVECTOR
static float4 splat (scalar s)
 splat scalar into each component of a vector
static float4 splat (const float4 &v, uint element)
 return a vector with all elements set to element n of v. 0 <= element <= 3
static float4 splat_x (const float4 &v)
 return a vector with all elements set to v.x
static float4 splat_y (const float4 &v)
 return a vector with all elements set to v.y
static float4 splat_z (const float4 &v)
 return a vector with all elements set to v.z
static float4 splat_w (const float4 &v)
 return a vector with all elements set to v.w
static float4 permute_control (unsigned int i0, unsigned int i1, unsigned int i2, unsigned int i3)
 return control vector for permute (see XMVectorPermuteControl for details)
static float4 permute (const float4 &v0, const float4 &v1, const float4 &control)
 merge components of 2 vectors into 1 (see XMVectorPermute for details)

Member Function Documentation

__forceinline void Math::float4::load ( const scalar *  ptr  )  [inherited]

load content from 16-byte-aligned memory

Load 4 floats from 16-byte-aligned memory.

__forceinline void Math::float4::loadu ( const scalar *  ptr  )  [inherited]

load content from unaligned memory

Load 4 floats from unaligned memory.

__forceinline void Math::float4::store ( scalar *  ptr  )  const [inherited]

write content to 16-byte-aligned memory through the write cache

Store to 16-byte-aligned float pointer.

__forceinline void Math::float4::storeu ( scalar *  ptr  )  const [inherited]

write content to unaligned memory through the write cache

Store to non-aligned float pointer.