cocos2d-x  3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Vec3 Class Reference

Defines a 3-element floating point vector. More...

#include <Vec3.h>

Public Member Functions

 Vec3 ()
 Constructs a new vector initialized to all zeros. More...
 
 Vec3 ()
 Constructs a new vector initialized to all zeros. More...
 
 Vec3 ()
 Constructs a new vector initialized to all zeros. More...
 
 Vec3 (float xx, float yy, float zz)
 Constructs a new vector initialized to the specified values. More...
 
 Vec3 ( var xx, var yy, var zz)
 Constructs a new vector initialized to the specified values. More...
 
 Vec3 ( local xx, local yy, local zz)
 Constructs a new vector initialized to the specified values. More...
 
 Vec3 (const float *array)
 Constructs a new vector from the values in the specified array. More...
 
 Vec3 (const Vec3 &p1, const Vec3 &p2)
 Constructs a vector that describes the direction between the specified points. More...
 
 Vec3 ( var p1, var p2)
 Constructs a vector that describes the direction between the specified points. More...
 
 Vec3 ( local p1, local p2)
 Constructs a vector that describes the direction between the specified points. More...
 
 Vec3 (const Vec3 &copy)
 Constructs a new vector that is a copy of the specified vector. More...
 
 ~Vec3 ()
 Destructor. More...
 
bool isZero () const
 Indicates whether this vector contains all zeros. More...
 
bool isOne () const
 Indicates whether this vector contains all ones. More...
 
void add (const Vec3 &v)
 Adds the elements of the specified vector to this one. More...
 
var add ( var v)
 Adds the elements of the specified vector to this one. More...
 
local add ( local v)
 Adds the elements of the specified vector to this one. More...
 
void clamp (const Vec3 &min, const Vec3 &max)
 Clamps this vector within the specified range. More...
 
void cross (const Vec3 &v)
 Sets this vector to the cross product between itself and the specified vector. More...
 
float distance (const Vec3 &v) const
 Returns the distance between this vector and v. More...
 
float distanceSquared (const Vec3 &v) const
 Returns the squared distance between this vector and v. More...
 
float dot (const Vec3 &v) const
 Returns the dot product of this vector and the specified vector. More...
 
float length () const
 Computes the length of this vector. More...
 
float lengthSquared () const
 Returns the squared length of this vector. More...
 
var lengthSquared ()
 Returns the squared length of this vector. More...
 
local lengthSquared ()
 Returns the squared length of this vector. More...
 
void negate ()
 Negates this vector. More...
 
var negate ()
 Negates this vector. More...
 
local negate ()
 Negates this vector. More...
 
void normalize ()
 Normalizes this vector. More...
 
var normalize ()
 Normalizes this vector. More...
 
local normalize ()
 Normalizes this vector. More...
 
Vec3 getNormalized () const
 Normalizes this vector and stores the result in dst. More...
 
var getNormalized ()
 Normalizes this vector and stores the result in dst. More...
 
local getNormalized ()
 Normalizes this vector and stores the result in dst. More...
 
void scale (float scalar)
 Scales all elements of this vector by the specified value. More...
 
void set (float xx, float yy, float zz)
 Sets the elements of this vector to the specified values. More...
 
var set ( var xx, var yy, var zz)
 Sets the elements of this vector to the specified values. More...
 
local set ( local xx, local yy, local zz)
 Sets the elements of this vector to the specified values. More...
 
void set (const float *array)
 Sets the elements of this vector from the values in the specified array. More...
 
void set (const Vec3 &v)
 Sets the elements of this vector to those in the specified vector. More...
 
void set (const Vec3 &p1, const Vec3 &p2)
 Sets this vector to the directional vector between the specified points. More...
 
var set ( var p1, var p2)
 Sets this vector to the directional vector between the specified points. More...
 
local set ( local p1, local p2)
 Sets this vector to the directional vector between the specified points. More...
 
void subtract (const Vec3 &v)
 Subtracts this vector and the specified vector as (this - v) and stores the result in this vector. More...
 
void smooth (const Vec3 &target, float elapsedTime, float responseTime)
 Updates this vector towards the given target using a smoothing function. More...
 
const Vec3 operator+ (const Vec3 &v) const
 Calculates the sum of this vector with the given vector. More...
 
Vec3operator+= (const Vec3 &v)
 Adds the given vector to this vector. More...
 
const Vec3 operator- (const Vec3 &v) const
 Calculates the difference of this vector with the given vector. More...
 
Vec3operator-= (const Vec3 &v)
 Subtracts the given vector from this vector. More...
 
local operator-= ( local v)
 Subtracts the given vector from this vector. More...
 
const Vec3 operator- () const
 Calculates the negation of this vector. More...
 
const Vec3 operator* (float s) const
 Calculates the scalar product of this vector with the given value. More...
 
local operator* ( local s)
 Calculates the scalar product of this vector with the given value. More...
 
Vec3operator*= (float s)
 Scales this vector by the given value. More...
 
const Vec3 operator/ (float s) const
 Returns the components of this vector divided by the given constant. More...
 
bool operator< (const Vec3 &rhs) const
 Returns true if the vector's scalar components are all greater that the ones of the vector it is compared against. More...
 
bool operator> (const Vec3 &rhs) const
 Returns true if the vector's scalar components are all smaller that the ones of the vector it is compared against. More...
 
bool operator== (const Vec3 &v) const
 Determines if this vector is equal to the given vector. More...
 
bool operator!= (const Vec3 &v) const
 Determines if this vector is not equal to the given vector. More...
 

Static Public Member Functions

static Vec3 fromColor (unsigned int color)
 Creates a new vector from an integer interpreted as an RGB value. More...
 
static float angle (const Vec3 &v1, const Vec3 &v2)
 Returns the angle (in radians) between the specified vectors. More...
 
static void add (const Vec3 &v1, const Vec3 &v2, Vec3 *dst)
 Adds the specified vectors and stores the result in dst. More...
 
static void clamp (const Vec3 &v, const Vec3 &min, const Vec3 &max, Vec3 *dst)
 Clamps the specified vector within the specified range and returns it in dst. More...
 
local clamp ( local v, local min, local max, local dst)
 Clamps the specified vector within the specified range and returns it in dst. More...
 
static void cross (const Vec3 &v1, const Vec3 &v2, Vec3 *dst)
 Computes the cross product of the specified vectors and stores the result in dst. More...
 
var cross ( var v1, var v2, var dst)
 Computes the cross product of the specified vectors and stores the result in dst. More...
 
local cross ( local v1, local v2, local dst)
 Computes the cross product of the specified vectors and stores the result in dst. More...
 
static float dot (const Vec3 &v1, const Vec3 &v2)
 Returns the dot product between the specified vectors. More...
 
local dot ( local v1, local v2)
 Returns the dot product between the specified vectors. More...
 
static void subtract (const Vec3 &v1, const Vec3 &v2, Vec3 *dst)
 Subtracts the specified vectors and stores the result in dst. More...
 
local subtract ( local v1, local v2, local dst)
 Subtracts the specified vectors and stores the result in dst. More...
 

Public Attributes

float x
 The x-coordinate. More...
 
float y
 The y-coordinate. More...
 
var y
 The y-coordinate. More...
 
local y
 The y-coordinate. More...
 
float z
 The z-coordinate. More...
 
var z
 The z-coordinate. More...
 
local z
 The z-coordinate. More...
 

Static Public Attributes

static const Vec3 ZERO
 equals to Vec3(0,0,0) More...
 
static const Vec3 ONE
 equals to Vec3(1,1,1) More...
 
var ONE
 equals to Vec3(1,1,1) More...
 
local ONE
 equals to Vec3(1,1,1) More...
 
static const Vec3 UNIT_X
 equals to Vec3(1,0,0) More...
 
var UNIT_X
 equals to Vec3(1,0,0) More...
 
local UNIT_X
 equals to Vec3(1,0,0) More...
 
static const Vec3 UNIT_Y
 equals to Vec3(0,1,0) More...
 
var UNIT_Y
 equals to Vec3(0,1,0) More...
 
local UNIT_Y
 equals to Vec3(0,1,0) More...
 
static const Vec3 UNIT_Z
 equals to Vec3(0,0,1) More...
 
var UNIT_Z
 equals to Vec3(0,0,1) More...
 
local UNIT_Z
 equals to Vec3(0,0,1) More...
 

Detailed Description

Defines a 3-element floating point vector.

When using a vector to represent a surface normal, the vector should typically be normalized. Other uses of directional vectors may wish to leave the magnitude of the vector intact. When used as a point, the elements of the vector represent a position in 3D space.

Constructor & Destructor Documentation

Vec3 ( )

Constructs a new vector initialized to all zeros.

var Vec3 ( )

Constructs a new vector initialized to all zeros.

local Vec3 ( )

Constructs a new vector initialized to all zeros.

Vec3 ( float  xx,
float  yy,
float  zz 
)

Constructs a new vector initialized to the specified values.

Parameters
xxThe x coordinate.
yyThe y coordinate.
zzThe z coordinate.
var Vec3 ( var  xx,
var  yy,
var  zz 
)

Constructs a new vector initialized to the specified values.

Parameters
xxThe x coordinate.
yyThe y coordinate.
zzThe z coordinate.
local Vec3 ( local  xx,
local  yy,
local  zz 
)

Constructs a new vector initialized to the specified values.

Parameters
xxThe x coordinate.
yyThe y coordinate.
zzThe z coordinate.
Vec3 ( 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.
var Vec3 ( var  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.
local Vec3 ( local  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.
Vec3 ( const Vec3 p1,
const Vec3 p2 
)

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

Parameters
p1The first point.
p2The second point.
var Vec3 ( var  p1,
var  p2 
)

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

Parameters
p1The first point.
p2The second point.
local Vec3 ( local  p1,
local  p2 
)

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

Parameters
p1The first point.
p2The second point.
Vec3 ( const Vec3 copy)

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

Parameters
copyThe vector to copy.
var Vec3 ( var  copy)

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

Parameters
copyThe vector to copy.
local Vec3 ( local  copy)

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

Parameters
copyThe vector to copy.
~Vec3 ( )

Destructor.

var ~Vec3 ( )

Destructor.

local ~Vec3 ( )

Destructor.

Member Function Documentation

void add ( const Vec3 v)

Adds the elements of the specified vector to this one.

Parameters
vThe vector to add.
var add ( var  v)

Adds the elements of the specified vector to this one.

Parameters
vThe vector to add.
local add ( local  v)

Adds the elements of the specified vector to this one.

Parameters
vThe vector to add.
static void add ( const Vec3 v1,
const Vec3 v2,
Vec3 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.
var add ( var  v1,
var  v2,
var  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.
local add ( local  v1,
local  v2,
local  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 angle ( const Vec3 v1,
const Vec3 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).
var angle ( var  v1,
var  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).
local angle ( local  v1,
local  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 clamp ( const Vec3 min,
const Vec3 max 
)

Clamps this vector within the specified range.

Parameters
minThe minimum value.
maxThe maximum value.
var clamp ( var  min,
var  max 
)

Clamps this vector within the specified range.

Parameters
minThe minimum value.
maxThe maximum value.
local clamp ( local  min,
local  max 
)

Clamps this vector within the specified range.

Parameters
minThe minimum value.
maxThe maximum value.
static void clamp ( const Vec3 v,
const Vec3 min,
const Vec3 max,
Vec3 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.
var clamp ( var  v,
var  min,
var  max,
var  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.
local clamp ( local  v,
local  min,
local  max,
local  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.
void cross ( const Vec3 v)

Sets this vector to the cross product between itself and the specified vector.

Parameters
vThe vector to compute the cross product with.
var cross ( var  v)

Sets this vector to the cross product between itself and the specified vector.

Parameters
vThe vector to compute the cross product with.
local cross ( local  v)

Sets this vector to the cross product between itself and the specified vector.

Parameters
vThe vector to compute the cross product with.
static void cross ( const Vec3 v1,
const Vec3 v2,
Vec3 dst 
)
static

Computes the cross product of the specified vectors and stores the result in dst.

Parameters
v1The first vector.
v2The second vector.
dstA vector to store the result in.
var cross ( var  v1,
var  v2,
var  dst 
)
static

Computes the cross product of the specified vectors and stores the result in dst.

Parameters
v1The first vector.
v2The second vector.
dstA vector to store the result in.
local cross ( local  v1,
local  v2,
local  dst 
)
static

Computes the cross product of the specified vectors and stores the result in dst.

Parameters
v1The first vector.
v2The second vector.
dstA vector to store the result in.
float distance ( const Vec3 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
var distance ( var  v)

Returns the distance between this vector and v.

Parameters
vThe other vector.
Returns
The distance between this vector and v.
See also
distanceSquared
local distance ( local  v)

Returns the distance between this vector and v.

Parameters
vThe other vector.
Returns
The distance between this vector and v.
See also
distanceSquared
float distanceSquared ( const Vec3 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
var distanceSquared ( var  v)

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
local distanceSquared ( local  v)

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 dot ( const Vec3 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.
var dot ( var  v)

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

Parameters
vThe vector to compute the dot product with.
Returns
The dot product.
local dot ( local  v)

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 dot ( const Vec3 v1,
const Vec3 v2 
)
static

Returns the dot product between the specified vectors.

Parameters
v1The first vector.
v2The second vector.
Returns
The dot product between the vectors.
var dot ( var  v1,
var  v2 
)
static

Returns the dot product between the specified vectors.

Parameters
v1The first vector.
v2The second vector.
Returns
The dot product between the vectors.
local dot ( local  v1,
local  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 Vec3 fromColor ( unsigned int  color)
static

Creates a new vector from an integer interpreted as an RGB value.

E.g. 0xff0000 represents red or the vector (1, 0, 0).

Parameters
colorThe integer to interpret as an RGB value.
Returns
A vector corresponding to the interpreted RGB color.
var fromColor ( var  color)
static

Creates a new vector from an integer interpreted as an RGB value.

E.g. 0xff0000 represents red or the vector (1, 0, 0).

Parameters
colorThe integer to interpret as an RGB value.
Returns
A vector corresponding to the interpreted RGB color.
local fromColor ( local  color)
static

Creates a new vector from an integer interpreted as an RGB value.

E.g. 0xff0000 represents red or the vector (1, 0, 0).

Parameters
colorThe integer to interpret as an RGB value.
Returns
A vector corresponding to the interpreted RGB color.
Vec3 getNormalized ( ) 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.
var getNormalized ( )

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.
local getNormalized ( )

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.
bool isOne ( ) const

Indicates whether this vector contains all ones.

Returns
true if this vector contains all ones, false otherwise.
var isOne ( )

Indicates whether this vector contains all ones.

Returns
true if this vector contains all ones, false otherwise.
local isOne ( )

Indicates whether this vector contains all ones.

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

Indicates whether this vector contains all zeros.

Returns
true if this vector contains all zeros, false otherwise.
var isZero ( )

Indicates whether this vector contains all zeros.

Returns
true if this vector contains all zeros, false otherwise.
local isZero ( )

Indicates whether this vector contains all zeros.

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

Computes the length of this vector.

Returns
The length of the vector.
See also
lengthSquared
var length ( )

Computes the length of this vector.

Returns
The length of the vector.
See also
lengthSquared
local length ( )

Computes the length of this vector.

Returns
The length of the vector.
See also
lengthSquared
float lengthSquared ( ) const

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
var 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
local 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
void negate ( )

Negates this vector.

var negate ( )

Negates this vector.

local negate ( )

Negates this vector.

void normalize ( )

Normalizes this vector.

This method normalizes this Vect3 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.
var normalize ( )

Normalizes this vector.

This method normalizes this Vect3 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.
local normalize ( )

Normalizes this vector.

This method normalizes this Vect3 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.
bool operator!= ( const Vec3 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.
bool operator!= ( var  v)
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.
bool operator!= ( local  v)
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 Vec3 operator* ( float  s) const
inline

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

Note: this does not modify this vector.

Parameters
sThe value to scale by.
Returns
The scaled vector.
const Vec3 operator* ( var  s)
inline

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

Note: this does not modify this vector.

Parameters
sThe value to scale by.
Returns
The scaled vector.
const Vec3 operator* ( local  s)
inline

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

Note: this does not modify this vector.

Parameters
sThe value to scale by.
Returns
The scaled vector.
Vec3& operator*= ( float  s)
inline

Scales this vector by the given value.

Parameters
sThe value to scale by.
Returns
This vector, after the scale occurs.
Vec3& operator*= ( var  s)
inline

Scales this vector by the given value.

Parameters
sThe value to scale by.
Returns
This vector, after the scale occurs.
Vec3& operator*= ( local  s)
inline

Scales this vector by the given value.

Parameters
sThe value to scale by.
Returns
This vector, after the scale occurs.
const Vec3 operator+ ( const Vec3 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 Vec3 operator+ ( var  v)
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 Vec3 operator+ ( local  v)
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.
Vec3& operator+= ( const Vec3 v)
inline

Adds the given vector to this vector.

Parameters
vThe vector to add.
Returns
This vector, after the addition occurs.
Vec3& operator+= ( var  v)
inline

Adds the given vector to this vector.

Parameters
vThe vector to add.
Returns
This vector, after the addition occurs.
Vec3& operator+= ( local  v)
inline

Adds the given vector to this vector.

Parameters
vThe vector to add.
Returns
This vector, after the addition occurs.
const Vec3 operator- ( const Vec3 v) const
inline

Calculates the difference of this vector with the given vector.

Note: this does not modify this vector.

Parameters
vThe vector to subtract.
Returns
The vector difference.
const Vec3 operator- ( var  v)
inline

Calculates the difference of this vector with the given vector.

Note: this does not modify this vector.

Parameters
vThe vector to subtract.
Returns
The vector difference.
const Vec3 operator- ( local  v)
inline

Calculates the difference of this vector with the given vector.

Note: this does not modify this vector.

Parameters
vThe vector to subtract.
Returns
The vector difference.
const Vec3 operator- ( ) const
inline

Calculates the negation of this vector.

Note: this does not modify this vector.

Returns
The negation of this vector.
const Vec3 operator- ( )
inline

Calculates the negation of this vector.

Note: this does not modify this vector.

Returns
The negation of this vector.
const Vec3 operator- ( )
inline

Calculates the negation of this vector.

Note: this does not modify this vector.

Returns
The negation of this vector.
Vec3& operator-= ( const Vec3 v)
inline

Subtracts the given vector from this vector.

Parameters
vThe vector to subtract.
Returns
This vector, after the subtraction occurs.
Vec3& operator-= ( var  v)
inline

Subtracts the given vector from this vector.

Parameters
vThe vector to subtract.
Returns
This vector, after the subtraction occurs.
Vec3& operator-= ( local  v)
inline

Subtracts the given vector from this vector.

Parameters
vThe vector to subtract.
Returns
This vector, after the subtraction occurs.
const Vec3 operator/ ( float  s) const
inline

Returns the components of this vector divided by the given constant.

Note: this does not modify this vector.

Parameters
sthe constant to divide this vector with
Returns
a smaller vector
const Vec3 operator/ ( var  s)
inline

Returns the components of this vector divided by the given constant.

Note: this does not modify this vector.

Parameters
sthe constant to divide this vector with
Returns
a smaller vector
const Vec3 operator/ ( local  s)
inline

Returns the components of this vector divided by the given constant.

Note: this does not modify this vector.

Parameters
sthe constant to divide this vector with
Returns
a smaller vector
bool operator< ( const Vec3 rhs) const
inline

Returns true if the vector's scalar components are all greater that the ones of the vector it is compared against.

bool operator< ( var  rhs)
inline

Returns true if the vector's scalar components are all greater that the ones of the vector it is compared against.

bool operator< ( local  rhs)
inline

Returns true if the vector's scalar components are all greater that the ones of the vector it is compared against.

bool operator== ( const Vec3 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.
bool operator== ( var  v)
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.
bool operator== ( local  v)
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.
bool operator> ( const Vec3 rhs) const
inline

Returns true if the vector's scalar components are all smaller that the ones of the vector it is compared against.

bool operator> ( var  rhs)
inline

Returns true if the vector's scalar components are all smaller that the ones of the vector it is compared against.

bool operator> ( local  rhs)
inline

Returns true if the vector's scalar components are all smaller that the ones of the vector it is compared against.

void scale ( float  scalar)

Scales all elements of this vector by the specified value.

Parameters
scalarThe scalar value.
var scale ( var  scalar)

Scales all elements of this vector by the specified value.

Parameters
scalarThe scalar value.
local scale ( local  scalar)

Scales all elements of this vector by the specified value.

Parameters
scalarThe scalar value.
void set ( float  xx,
float  yy,
float  zz 
)

Sets the elements of this vector to the specified values.

Parameters
xxThe new x coordinate.
yyThe new y coordinate.
zzThe new z coordinate.
var set ( var  xx,
var  yy,
var  zz 
)

Sets the elements of this vector to the specified values.

Parameters
xxThe new x coordinate.
yyThe new y coordinate.
zzThe new z coordinate.
local set ( local  xx,
local  yy,
local  zz 
)

Sets the elements of this vector to the specified values.

Parameters
xxThe new x coordinate.
yyThe new y coordinate.
zzThe new z coordinate.
void 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.
var set ( var  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.
local set ( local  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.
void set ( const Vec3 v)

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

Parameters
vThe vector to copy.
var set ( var  v)

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

Parameters
vThe vector to copy.
local set ( local  v)

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

Parameters
vThe vector to copy.
void set ( const Vec3 p1,
const Vec3 p2 
)

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

var set ( var  p1,
var  p2 
)

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

local set ( local  p1,
local  p2 
)

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

void smooth ( const Vec3 target,
float  elapsedTime,
float  responseTime 
)

Updates this vector towards the given target using a smoothing function.

The given response time determines the amount of smoothing (lag). A longer response time yields a smoother result and more lag. To force this vector to follow the target closely, provide a response time that is very small relative to the given elapsed time.

Parameters
targettarget value.
elapsedTimeelapsed time between calls.
responseTimeresponse time (in the same units as elapsedTime).
var smooth ( var  target,
var  elapsedTime,
var  responseTime 
)

Updates this vector towards the given target using a smoothing function.

The given response time determines the amount of smoothing (lag). A longer response time yields a smoother result and more lag. To force this vector to follow the target closely, provide a response time that is very small relative to the given elapsed time.

Parameters
targettarget value.
elapsedTimeelapsed time between calls.
responseTimeresponse time (in the same units as elapsedTime).
local smooth ( local  target,
local  elapsedTime,
local  responseTime 
)

Updates this vector towards the given target using a smoothing function.

The given response time determines the amount of smoothing (lag). A longer response time yields a smoother result and more lag. To force this vector to follow the target closely, provide a response time that is very small relative to the given elapsed time.

Parameters
targettarget value.
elapsedTimeelapsed time between calls.
responseTimeresponse time (in the same units as elapsedTime).
void subtract ( const Vec3 v)

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

Parameters
vThe vector to subtract.
var subtract ( var  v)

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

Parameters
vThe vector to subtract.
local subtract ( local  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 subtract ( const Vec3 v1,
const Vec3 v2,
Vec3 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.
var subtract ( var  v1,
var  v2,
var  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.
local subtract ( local  v1,
local  v2,
local  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.

Member Data Documentation

const Vec3 ONE
static

equals to Vec3(1,1,1)

var ONE
static

equals to Vec3(1,1,1)

local ONE
static

equals to Vec3(1,1,1)

const Vec3 UNIT_X
static

equals to Vec3(1,0,0)

var UNIT_X
static

equals to Vec3(1,0,0)

local UNIT_X
static

equals to Vec3(1,0,0)

const Vec3 UNIT_Y
static

equals to Vec3(0,1,0)

var UNIT_Y
static

equals to Vec3(0,1,0)

local UNIT_Y
static

equals to Vec3(0,1,0)

const Vec3 UNIT_Z
static

equals to Vec3(0,0,1)

var UNIT_Z
static

equals to Vec3(0,0,1)

local UNIT_Z
static

equals to Vec3(0,0,1)

float x

The x-coordinate.

var x

The x-coordinate.

local x

The x-coordinate.

float y

The y-coordinate.

var y

The y-coordinate.

local y

The y-coordinate.

float z

The z-coordinate.

var z

The z-coordinate.

local z

The z-coordinate.

const Vec3 ZERO
static

equals to Vec3(0,0,0)


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