overview wiki api reference download
 All Classes Functions Variables Typedefs Enumerations Enumerator
Public Member Functions | Static Public Member Functions | Public Attributes
gameplay::Vector4 Class Reference

#include <Vector4.h>

List of all members.

Public Member Functions

 Vector4 ()
 Vector4 (float x, float y, float z, float w)
 Vector4 (const float *array)
 Vector4 (const Vector4 &p1, const Vector4 &p2)
 Vector4 (const Vector4 &copy)
 ~Vector4 ()
bool isZero () const
bool isOne () const
void add (const Vector4 &v)
void clamp (const Vector4 &min, const Vector4 &max)
float distance (const Vector4 &v) const
float distanceSquared (const Vector4 &v) const
float dot (const Vector4 &v) const
float length () const
float lengthSquared () const
void negate ()
Vector4normalize ()
void normalize (Vector4 *dst) const
void scale (float scalar)
void set (float x, float y, float z, float w)
void set (const float *array)
void set (const Vector4 &v)
void set (const Vector4 &p1, const Vector4 &p2)
void subtract (const Vector4 &v)
const Vector4 operator+ (const Vector4 &v) const
Vector4operator+= (const Vector4 &v)
const Vector4 operator- (const Vector4 &v) const
Vector4operator-= (const Vector4 &v)
const Vector4 operator- () const
const Vector4 operator* (float x) const
Vector4operator*= (float x)
const Vector4 operator/ (float x) const
bool operator< (const Vector4 &v) const
bool operator== (const Vector4 &v) const
bool operator!= (const Vector4 &v) const

Static Public Member Functions

static Vector4 fromColor (unsigned int color)
static const Vector4zero ()
static const Vector4one ()
static const Vector4unitX ()
static const Vector4unitY ()
static const Vector4unitZ ()
static const Vector4unitW ()
static float angle (const Vector4 &v1, const Vector4 &v2)
static void add (const Vector4 &v1, const Vector4 &v2, Vector4 *dst)
static void clamp (const Vector4 &v, const Vector4 &min, const Vector4 &max, Vector4 *dst)
static float dot (const Vector4 &v1, const Vector4 &v2)
static void subtract (const Vector4 &v1, const Vector4 &v2, Vector4 *dst)

Public Attributes

float x
float y
float z
float w

Detailed Description

Defines 4-element floating point vector.


Constructor & Destructor Documentation

Constructs a new vector initialized to all zeros.

gameplay::Vector4::Vector4 ( float  x,
float  y,
float  z,
float  w 
)

Constructs a new vector initialized to the specified values.

Parameters:
xThe x coordinate.
yThe y coordinate.
zThe z coordinate.
wThe w coordinate.
gameplay::Vector4::Vector4 ( const float *  array)

Constructs a new vector from the values in the specified array.

Parameters:
arrayAn array containing the elements of the vector in the order x, y, z, w.
gameplay::Vector4::Vector4 ( const Vector4 p1,
const Vector4 p2 
)

Constructs a vector that describes the direction between the specified points.

Parameters:
p1The first point.
p2The second point.

Constructor.

Creates a new vector that is a copy of the specified vector.

Parameters:
copyThe vector to copy.

Destructor.


Member Function Documentation

void gameplay::Vector4::add ( const Vector4 v)

Adds the elements of the specified vector to this one.

Parameters:
vThe vector to add.
static void gameplay::Vector4::add ( const Vector4 v1,
const Vector4 v2,
Vector4 dst 
) [static]

Adds the specified vectors and stores the result in dst.

Parameters:
v1The first vector.
v2The second vector.
dstA vector to store the result in.
static float gameplay::Vector4::angle ( const Vector4 v1,
const Vector4 v2 
) [static]

Returns the angle (in radians) between the specified vectors.

Parameters:
v1The first vector.
v2The second vector.
Returns:
The angle between the two vectors (in radians).
void gameplay::Vector4::clamp ( const Vector4 min,
const Vector4 max 
)

Clamps this vector within the specified range.

Parameters:
minThe minimum value.
maxThe maximum value.
static void gameplay::Vector4::clamp ( const Vector4 v,
const Vector4 min,
const Vector4 max,
Vector4 dst 
) [static]

Clamps the specified vector within the specified range and returns it in dst.

Parameters:
vThe vector to clamp.
minThe minimum value.
maxThe maximum value.
dstA vector to store the result in.
float gameplay::Vector4::distance ( const Vector4 v) const

Returns the distance between this vector and v.

Parameters:
vThe other vector.
Returns:
The distance between this vector and v.
See also:
distanceSquared
float gameplay::Vector4::distanceSquared ( const Vector4 v) const

Returns the squared distance between this vector and v.

When it is not necessary to get the exact distance between two vectors (for example, when simply comparing the distance between different vectors), it is advised to use this method instead of distance.

Parameters:
vThe other vector.
Returns:
The squared distance between this vector and v.
See also:
distance
float gameplay::Vector4::dot ( const Vector4 v) const

Returns the dot product of this vector and the specified vector.

Parameters:
vThe vector to compute the dot product with.
Returns:
The dot product.
static float gameplay::Vector4::dot ( const Vector4 v1,
const Vector4 v2 
) [static]

Returns the dot product between the specified vectors.

Parameters:
v1The first vector.
v2The second vector.
Returns:
The dot product between the vectors.
static Vector4 gameplay::Vector4::fromColor ( unsigned int  color) [static]

Creates a new vector from an integer interpreted as an RGBA value. E.g. 0xff0000ff represents opaque red or the vector (1, 0, 0, 1).

Parameters:
colorThe integer to interpret as an RGBA value.
Returns:
A vector corresponding to the interpreted RGBA color.
bool gameplay::Vector4::isOne ( ) const

Indicates whether this vector contains all ones.

Returns:
true if this vector contains all ones, false otherwise.
bool gameplay::Vector4::isZero ( ) const

Indicates whether this vector contains all zeros.

Returns:
true if this vector contains all zeros, false otherwise.
float gameplay::Vector4::length ( ) const

Computes the length of this vector.

Returns:
The length of the vector.
See also:
lengthSquared

Returns the squared length of this vector.

When it is not necessary to get the exact length of a vector (for example, when simply comparing the lengths of different vectors), it is advised to use this method instead of length.

Returns:
The squared length of the vector.
See also:
length

Negates this vector.

Normalizes this vector.

This method normalizes this Vector4 so that it is of unit length (in other words, the length of the vector after calling this method will be 1.0f). If the vector already has unit length or if the length of the vector is zero, this method does nothing.

Returns:
This vector, after the normalization occurs.
void gameplay::Vector4::normalize ( Vector4 dst) const

Normalizes this vector and stores the result in dst.

If the vector already has unit length or if the length of the vector is zero, this method simply copies the current vector into dst.

Parameters:
dstThe destination vector.
static const Vector4& gameplay::Vector4::one ( ) [static]

Returns the one vector.

Returns:
The 4-element vector of 1s.
bool gameplay::Vector4::operator!= ( const Vector4 v) const [inline]

Determines if this vector is not equal to the given vector.

Parameters:
vThe vector to compare against.
Returns:
True if this vector is not equal to the given vector, false otherwise.
const Vector4 gameplay::Vector4::operator* ( float  x) const [inline]

Calculates the scalar product of this vector with the given value.

Note: this does not modify this vector.

Parameters:
xThe value to scale by.
Returns:
The scaled vector.
Vector4& gameplay::Vector4::operator*= ( float  x) [inline]

Scales this vector by the given value.

Parameters:
xThe value to scale by.
Returns:
This vector, after the scale occurs.
const Vector4 gameplay::Vector4::operator+ ( const Vector4 v) const [inline]

Calculates the sum of this vector with the given vector.

Note: this does not modify this vector.

Parameters:
vThe vector to add.
Returns:
The vector sum.
Vector4& gameplay::Vector4::operator+= ( const Vector4 v) [inline]

Adds the given vector to this vector.

Parameters:
vThe vector to add.
Returns:
This vector, after the addition occurs.
const Vector4 gameplay::Vector4::operator- ( const Vector4 v) const [inline]

Calculates the sum of this vector with the given vector.

Note: this does not modify this vector.

Parameters:
vThe vector to add.
Returns:
The vector sum.
const Vector4 gameplay::Vector4::operator- ( ) const [inline]

Calculates the negation of this vector.

Note: this does not modify this vector.

Returns:
The negation of this vector.
Vector4& gameplay::Vector4::operator-= ( const Vector4 v) [inline]

Subtracts the given vector from this vector.

Parameters:
vThe vector to subtract.
Returns:
This vector, after the subtraction occurs.
const Vector4 gameplay::Vector4::operator/ ( float  x) const [inline]

Returns the components of this vector divided by the given constant

Note: this does not modify this vector.

Parameters:
xthe constant to divide this vector with
Returns:
a smaller vector
bool gameplay::Vector4::operator< ( const Vector4 v) const [inline]

Determines if this vector is less than the given vector.

Parameters:
vThe vector to compare against.
Returns:
True if this vector is less than the given vector, false otherwise.
bool gameplay::Vector4::operator== ( const Vector4 v) const [inline]

Determines if this vector is equal to the given vector.

Parameters:
vThe vector to compare against.
Returns:
True if this vector is equal to the given vector, false otherwise.
void gameplay::Vector4::scale ( float  scalar)

Scales all elements of this vector by the specified value.

Parameters:
scalarThe scalar value.
void gameplay::Vector4::set ( float  x,
float  y,
float  z,
float  w 
)

Sets the elements of this vector to the specified values.

Parameters:
xThe new x coordinate.
yThe new y coordinate.
zThe new z coordinate.
wThe new w coordinate.
void gameplay::Vector4::set ( const float *  array)

Sets the elements of this vector from the values in the specified array.

Parameters:
arrayAn array containing the elements of the vector in the order x, y, z, w.
void gameplay::Vector4::set ( const Vector4 v)

Sets the elements of this vector to those in the specified vector.

Parameters:
vThe vector to copy.
void gameplay::Vector4::set ( const Vector4 p1,
const Vector4 p2 
)

Sets this vector to the directional vector between the specified points.

Parameters:
p1The first point.
p2The second point.
void gameplay::Vector4::subtract ( const Vector4 v)

Subtracts this vector and the specified vector as (this - v) and stores the result in this vector.

Parameters:
vThe vector to subtract.
static void gameplay::Vector4::subtract ( const Vector4 v1,
const Vector4 v2,
Vector4 dst 
) [static]

Subtracts the specified vectors and stores the result in dst. The resulting vector is computed as (v1 - v2).

Parameters:
v1The first vector.
v2The second vector.
dstThe destination vector.
static const Vector4& gameplay::Vector4::unitW ( ) [static]

Returns the unit w vector.

Returns:
The 4-element unit vector along the w axis.
static const Vector4& gameplay::Vector4::unitX ( ) [static]

Returns the unit x vector.

Returns:
The 4-element unit vector along the x axis.
static const Vector4& gameplay::Vector4::unitY ( ) [static]

Returns the unit y vector.

Returns:
The 4-element unit vector along the y axis.
static const Vector4& gameplay::Vector4::unitZ ( ) [static]

Returns the unit z vector.

Returns:
The 4-element unit vector along the z axis.
static const Vector4& gameplay::Vector4::zero ( ) [static]

Returns the zero vector.

Returns:
The 4-element vector of 0s.

Member Data Documentation

The w-coordinate.

The x-coordinate.

The y-coordinate.

The z-coordinate.

 All Classes Functions Variables Typedefs Enumerations Enumerator