Defines 4-element floating point vector.
More...
#include <Vec4.h>
Public Member Functions
Constructs a new vector initialized to all zeros.
More...
Vec4 (float xx, float yy, float zz, float ww)
Constructs a new vector initialized to the specified values.
More...
Vec4 ( var xx, var yy, var zz, var ww)
Constructs a new vector initialized to the specified values.
More...
Vec4 ( local xx, local yy, local zz, local ww)
Constructs a new vector initialized to the specified values.
More...
Vec4 (const float *array)
Constructs a new vector from the values in the specified array.
More...
Constructs a vector that describes the direction between the specified points.
More...
Constructs a vector that describes the direction between the specified points.
More...
Vec4 ( local p1, local p2)
Constructs a vector that describes the direction between the specified points.
More...
Indicates whether this vector contains all zeros.
More...
Indicates whether this vector contains all ones.
More...
Adds the elements of the specified vector to this one.
More...
Adds the elements of the specified vector to this one.
More...
Adds the elements of the specified vector to this one.
More...
Clamps this vector within the specified range.
More...
Returns the distance between this vector and v.
More...
Returns the distance between this vector and v.
More...
Returns the distance between this vector and v.
More...
Returns the squared distance between this vector and v.
More...
Returns the dot product of this vector and the specified vector.
More...
Computes the length of this vector.
More...
Returns the squared length of this vector.
More...
Returns the squared length of this vector.
More...
Returns the squared length of this vector.
More...
Normalizes this vector and stores the result in dst.
More...
Normalizes this vector and stores the result in dst.
More...
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, float ww)
Sets the elements of this vector to the specified values.
More...
var
set ( var xx, var yy, var zz, var ww)
Sets the elements of this vector to the specified values.
More...
local
set ( local xx, local yy, local zz, local ww)
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...
Sets the elements of this vector to those in the specified vector.
More...
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...
Subtracts this vector and the specified vector as (this - v) and stores the result in this vector.
More...
Calculates the sum of this vector with the given vector.
More...
Adds the given vector to this vector.
More...
Calculates the sum of this vector with the given vector.
More...
Subtracts the given vector from this vector.
More...
Calculates the negation of this vector.
More...
Calculates the scalar product of this vector with the given value.
More...
Calculates the scalar product of this vector with the given value.
More...
Scales this vector by the given value.
More...
Returns the components of this vector divided by the given constant.
More...
Determines if this vector is less than the given vector.
More...
Determines if this vector is less than the given vector.
More...
Determines if this vector is less than the given vector.
More...
Determines if this vector is equal to the given vector.
More...
Determines if this vector is not equal to the given vector.
More...
Static Public Member Functions
Creates a new vector from an integer interpreted as an RGBA value.
More...
Returns the angle (in radians) between the specified vectors.
More...
Adds the specified vectors and stores the result in dst.
More...
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...
Returns the dot product between the specified vectors.
More...
local
dot ( local v1, local v2)
Returns the dot product between the specified vectors.
More...
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
Static Public Attributes
Detailed Description
Defines 4-element floating point vector.
Constructor & Destructor Documentation
Constructs a new vector initialized to all zeros.
Constructs a new vector initialized to all zeros.
Constructs a new vector initialized to all zeros.
float
yy,
float
zz,
float
ww
)
Constructs a new vector initialized to the specified values.
- Parameters
-
xx The x coordinate.
yy The y coordinate.
zz The z coordinate.
ww The w coordinate.
Constructs a new vector initialized to the specified values.
- Parameters
-
xx The x coordinate.
yy The y coordinate.
zz The z coordinate.
ww The w coordinate.
local
yy,
local
zz,
local
ww
)
Constructs a new vector initialized to the specified values.
- Parameters
-
xx The x coordinate.
yy The y coordinate.
zz The z coordinate.
ww The w coordinate.
Vec4
(
const float *
array )
Constructs a new vector from the values in the specified array.
- Parameters
-
array An array containing the elements of the vector in the order x, y, z, w.
Constructs a new vector from the values in the specified array.
- Parameters
-
array An array containing the elements of the vector in the order x, y, z, w.
local
Vec4
(
local
array )
Constructs a new vector from the values in the specified array.
- Parameters
-
array An array containing the elements of the vector in the order x, y, z, w.
Constructs a vector that describes the direction between the specified points.
- Parameters
-
p1 The first point.
p2 The second point.
Constructs a vector that describes the direction between the specified points.
- Parameters
-
p1 The first point.
p2 The second point.
Constructs a vector that describes the direction between the specified points.
- Parameters
-
p1 The first point.
p2 The second point.
Constructor.
Creates a new vector that is a copy of the specified vector.
- Parameters
-
copy The vector to copy.
Constructor.
Creates a new vector that is a copy of the specified vector.
- Parameters
-
copy The vector to copy.
local
Vec4
(
local
copy )
Constructor.
Creates a new vector that is a copy of the specified vector.
- Parameters
-
copy The vector to copy.
Member Function Documentation
void add
(
const
Vec4 &
v )
Adds the elements of the specified vector to this one.
- Parameters
-
v The vector to add.
Adds the elements of the specified vector to this one.
- Parameters
-
v The vector to add.
Adds the elements of the specified vector to this one.
- Parameters
-
v The vector to add.
static void add
(
const
Vec4 &
v1,
)
static
Adds the specified vectors and stores the result in dst.
- Parameters
-
v1 The first vector.
v2 The second vector.
dst A 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
-
v1 The first vector.
v2 The second vector.
dst A 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
-
v1 The first vector.
v2 The second vector.
dst A vector to store the result in.
static float angle
(
const
Vec4 &
v1,
)
static
Returns the angle (in radians) between the specified vectors.
- Parameters
-
v1 The first vector.
v2 The 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
-
v1 The first vector.
v2 The 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
-
v1 The first vector.
v2 The second vector.
- Returns
- The angle between the two vectors (in radians).
void clamp
(
const
Vec4 &
min,
)
Clamps this vector within the specified range.
- Parameters
-
min The minimum value.
max The maximum value.
var clamp
(
var
min,
var
max
)
Clamps this vector within the specified range.
- Parameters
-
min The minimum value.
max The maximum value.
local clamp
(
local
min,
local
max
)
Clamps this vector within the specified range.
- Parameters
-
min The minimum value.
max The maximum value.
static void clamp
(
const
Vec4 &
v,
)
static
Clamps the specified vector within the specified range and returns it in dst.
- Parameters
-
v The vector to clamp.
min The minimum value.
max The maximum value.
dst A 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
-
v The vector to clamp.
min The minimum value.
max The maximum value.
dst A 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
-
v The vector to clamp.
min The minimum value.
max The maximum value.
dst A vector to store the result in.
float distance
(
const
Vec4 &
v )
const
Returns the distance between this vector and v.
- Parameters
-
v The other vector.
- Returns
- The distance between this vector and v.
- See also
- distanceSquared
Returns the distance between this vector and v.
- Parameters
-
v The 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
-
v The other vector.
- Returns
- The distance between this vector and v.
- See also
- distanceSquared
float distanceSquared
(
const
Vec4 &
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
-
v The 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
-
v The 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
-
v The other vector.
- Returns
- The squared distance between this vector and v.
- See also
- distance
float dot
(
const
Vec4 &
v )
const
Returns the dot product of this vector and the specified vector.
- Parameters
-
v The vector to compute the dot product with.
- Returns
- The dot product.
Returns the dot product of this vector and the specified vector.
- Parameters
-
v The vector to compute the dot product with.
- Returns
- The dot product.
Returns the dot product of this vector and the specified vector.
- Parameters
-
v The vector to compute the dot product with.
- Returns
- The dot product.
static float dot
(
const
Vec4 &
v1,
)
static
Returns the dot product between the specified vectors.
- Parameters
-
v1 The first vector.
v2 The 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
-
v1 The first vector.
v2 The 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
-
v1 The first vector.
v2 The second vector.
- Returns
- The dot product between the vectors.
static
Vec4 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
-
color The integer to interpret as an RGBA value.
- Returns
- A vector corresponding to the interpreted RGBA color.
var fromColor
(
var
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
-
color The integer to interpret as an RGBA value.
- Returns
- A vector corresponding to the interpreted RGBA color.
local fromColor
(
local
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
-
color The integer to interpret as an RGBA value.
- Returns
- A vector corresponding to the interpreted RGBA color.
Vec4 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
-
dst The destination vector.
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
-
dst The destination vector.
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
-
dst The destination vector.
Indicates whether this vector contains all ones.
- Returns
- true if this vector contains all ones, false otherwise.
Indicates whether this vector contains all ones.
- Returns
- true if this vector contains all ones, false otherwise.
Indicates whether this vector contains all ones.
- Returns
- true if this vector contains all ones, false otherwise.
Indicates whether this vector contains all zeros.
- Returns
- true if this vector contains all zeros, false otherwise.
Indicates whether this vector contains all zeros.
- Returns
- true if this vector contains all zeros, false otherwise.
Indicates whether this vector contains all zeros.
- Returns
- true if this vector contains all zeros, false otherwise.
Computes the length of this vector.
- Returns
- The length of the vector.
- See also
- lengthSquared
Computes the length of this vector.
- Returns
- The length of the vector.
- See also
- lengthSquared
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
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
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
Normalizes this vector.
This method normalizes this Vec4 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.
Normalizes this vector.
This method normalizes this Vec4 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.
Normalizes this vector.
This method normalizes this Vec4 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
Vec4 &
v )
const
inline
Determines if this vector is not equal to the given vector.
- Parameters
-
v The 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
-
v The 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
-
v The vector to compare against.
- Returns
- True if this vector is not equal to the given vector, false otherwise.
const
Vec4 operator*
(
float
s )
const
inline
Calculates the scalar product of this vector with the given value.
Note: this does not modify this vector.
- Parameters
-
s The value to scale by.
- Returns
- The scaled vector.
const
Vec4 operator*
(
var
s )
inline
Calculates the scalar product of this vector with the given value.
Note: this does not modify this vector.
- Parameters
-
s The value to scale by.
- Returns
- The scaled vector.
const
Vec4 operator*
(
local
s )
inline
Calculates the scalar product of this vector with the given value.
Note: this does not modify this vector.
- Parameters
-
s The value to scale by.
- Returns
- The scaled vector.
Vec4& operator*=
(
float
s )
inline
Scales this vector by the given value.
- Parameters
-
s The value to scale by.
- Returns
- This vector, after the scale occurs.
Vec4& operator*=
(
var
s )
inline
Scales this vector by the given value.
- Parameters
-
s The value to scale by.
- Returns
- This vector, after the scale occurs.
Vec4& operator*=
(
local
s )
inline
Scales this vector by the given value.
- Parameters
-
s The value to scale by.
- Returns
- This vector, after the scale occurs.
const
Vec4 operator+
(
const
Vec4 &
v )
const
inline
Calculates the sum of this vector with the given vector.
Note: this does not modify this vector.
- Parameters
-
v The vector to add.
- Returns
- The vector sum.
const
Vec4 operator+
(
var
v )
inline
Calculates the sum of this vector with the given vector.
Note: this does not modify this vector.
- Parameters
-
v The vector to add.
- Returns
- The vector sum.
const
Vec4 operator+
(
local
v )
inline
Calculates the sum of this vector with the given vector.
Note: this does not modify this vector.
- Parameters
-
v The vector to add.
- Returns
- The vector sum.
Adds the given vector to this vector.
- Parameters
-
v The vector to add.
- Returns
- This vector, after the addition occurs.
Vec4& operator+=
(
var
v )
inline
Adds the given vector to this vector.
- Parameters
-
v The vector to add.
- Returns
- This vector, after the addition occurs.
Vec4& operator+=
(
local
v )
inline
Adds the given vector to this vector.
- Parameters
-
v The vector to add.
- Returns
- This vector, after the addition occurs.
const
Vec4 operator-
(
const
Vec4 &
v )
const
inline
Calculates the sum of this vector with the given vector.
Note: this does not modify this vector.
- Parameters
-
v The vector to add.
- Returns
- The vector sum.
const
Vec4 operator-
(
var
v )
inline
Calculates the sum of this vector with the given vector.
Note: this does not modify this vector.
- Parameters
-
v The vector to add.
- Returns
- The vector sum.
const
Vec4 operator-
(
local
v )
inline
Calculates the sum of this vector with the given vector.
Note: this does not modify this vector.
- Parameters
-
v The vector to add.
- Returns
- The vector sum.
const
Vec4 operator-
(
)
const
inline
Calculates the negation of this vector.
Note: this does not modify this vector.
- Returns
- The negation of this vector.
Calculates the negation of this vector.
Note: this does not modify this vector.
- Returns
- The negation of this vector.
Calculates the negation of this vector.
Note: this does not modify this vector.
- Returns
- The negation of this vector.
Subtracts the given vector from this vector.
- Parameters
-
v The vector to subtract.
- Returns
- This vector, after the subtraction occurs.
Vec4& operator-=
(
var
v )
inline
Subtracts the given vector from this vector.
- Parameters
-
v The vector to subtract.
- Returns
- This vector, after the subtraction occurs.
Vec4& operator-=
(
local
v )
inline
Subtracts the given vector from this vector.
- Parameters
-
v The vector to subtract.
- Returns
- This vector, after the subtraction occurs.
const
Vec4 operator/
(
float
s )
const
inline
Returns the components of this vector divided by the given constant.
Note: this does not modify this vector.
- Parameters
-
s the constant to divide this vector with
- Returns
- a smaller vector
const
Vec4 operator/
(
var
s )
inline
Returns the components of this vector divided by the given constant.
Note: this does not modify this vector.
- Parameters
-
s the constant to divide this vector with
- Returns
- a smaller vector
const
Vec4 operator/
(
local
s )
inline
Returns the components of this vector divided by the given constant.
Note: this does not modify this vector.
- Parameters
-
s the constant to divide this vector with
- Returns
- a smaller vector
bool operator<
(
const
Vec4 &
v )
const
inline
Determines if this vector is less than the given vector.
- Parameters
-
v The vector to compare against.
- Returns
- True if this vector is less than the given vector, false otherwise.
bool operator<
(
var
v )
inline
Determines if this vector is less than the given vector.
- Parameters
-
v The vector to compare against.
- Returns
- True if this vector is less than the given vector, false otherwise.
bool operator<
(
local
v )
inline
Determines if this vector is less than the given vector.
- Parameters
-
v The vector to compare against.
- Returns
- True if this vector is less than the given vector, false otherwise.
bool operator==
(
const
Vec4 &
v )
const
inline
Determines if this vector is equal to the given vector.
- Parameters
-
v The 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
-
v The 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
-
v The vector to compare against.
- Returns
- True if this vector is equal to the given vector, false otherwise.
void scale
(
float
scalar )
Scales all elements of this vector by the specified value.
- Parameters
-
scalar The scalar value.
Scales all elements of this vector by the specified value.
- Parameters
-
scalar The scalar value.
local scale
(
local
scalar )
Scales all elements of this vector by the specified value.
- Parameters
-
scalar The scalar value.
void set
(
float
xx,
float
yy,
float
zz,
float
ww
)
Sets the elements of this vector to the specified values.
- Parameters
-
xx The new x coordinate.
yy The new y coordinate.
zz The new z coordinate.
ww The new w coordinate.
var set
(
var
xx,
var
yy,
var
zz,
var
ww
)
Sets the elements of this vector to the specified values.
- Parameters
-
xx The new x coordinate.
yy The new y coordinate.
zz The new z coordinate.
ww The new w coordinate.
local set
(
local
xx,
local
yy,
local
zz,
local
ww
)
Sets the elements of this vector to the specified values.
- Parameters
-
xx The new x coordinate.
yy The new y coordinate.
zz The new z coordinate.
ww The new w coordinate.
void set
(
const float *
array )
Sets the elements of this vector from the values in the specified array.
- Parameters
-
array An array containing the elements of the vector in the order x, y, z, w.
Sets the elements of this vector from the values in the specified array.
- Parameters
-
array An array containing the elements of the vector in the order x, y, z, w.
local set
(
local
array )
Sets the elements of this vector from the values in the specified array.
- Parameters
-
array An array containing the elements of the vector in the order x, y, z, w.
void set
(
const
Vec4 &
v )
Sets the elements of this vector to those in the specified vector.
- Parameters
-
v The vector to copy.
Sets the elements of this vector to those in the specified vector.
- Parameters
-
v The vector to copy.
Sets the elements of this vector to those in the specified vector.
- Parameters
-
v The vector to copy.
void set
(
const
Vec4 &
p1,
)
Sets this vector to the directional vector between the specified points.
- Parameters
-
p1 The first point.
p2 The second point.
var set
(
var
p1,
var
p2
)
Sets this vector to the directional vector between the specified points.
- Parameters
-
p1 The first point.
p2 The second point.
local set
(
local
p1,
local
p2
)
Sets this vector to the directional vector between the specified points.
- Parameters
-
p1 The first point.
p2 The second point.
void subtract
(
const
Vec4 &
v )
Subtracts this vector and the specified vector as (this - v) and stores the result in this vector.
- Parameters
-
v The vector to subtract.
Subtracts this vector and the specified vector as (this - v) and stores the result in this vector.
- Parameters
-
v The 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
-
v The vector to subtract.
static void subtract
(
const
Vec4 &
v1,
)
static
Subtracts the specified vectors and stores the result in dst.
The resulting vector is computed as (v1 - v2).
- Parameters
-
v1 The first vector.
v2 The second vector.
dst The 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
-
v1 The first vector.
v2 The second vector.
dst The 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
-
v1 The first vector.
v2 The second vector.
dst The destination vector.
Member Data Documentation
The documentation for this class was generated from the following file:
- /Users/minggo/SourceCode/cocos2d-x/cocos/math/Vec4.h