cocos2d-x
3.3
|
Defines 4-element floating point vector. More...
#include <Vec4.h>
Public Member Functions | |
Vec4 () | |
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 (const float *array) | |
Constructs a new vector from the values in the specified array. More... | |
Vec4 (const Vec4 &p1, const Vec4 &p2) | |
Constructs a vector that describes the direction between the specified points. More... | |
Vec4 (const Vec4 ©) | |
Constructor. More... | |
~Vec4 () | |
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 Vec4 &v) |
Adds the elements of the specified vector to this one. More... | |
void | clamp (const Vec4 &min, const Vec4 &max) |
Clamps this vector within the specified range. More... | |
float | distance (const Vec4 &v) const |
Returns the distance between this vector and v. More... | |
float | distanceSquared (const Vec4 &v) const |
Returns the squared distance between this vector and v. More... | |
float | dot (const Vec4 &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... | |
void | negate () |
Negates this vector. More... | |
void | normalize () |
Normalizes this vector. More... | |
Vec4 | getNormalized () const |
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... | |
void | set (const float *array) |
Sets the elements of this vector from the values in the specified array. More... | |
void | set (const Vec4 &v) |
Sets the elements of this vector to those in the specified vector. More... | |
void | set (const Vec4 &p1, const Vec4 &p2) |
Sets this vector to the directional vector between the specified points. More... | |
void | subtract (const Vec4 &v) |
Subtracts this vector and the specified vector as (this - v) and stores the result in this vector. More... | |
const Vec4 | operator+ (const Vec4 &v) const |
Calculates the sum of this vector with the given vector. More... | |
Vec4 & | operator+= (const Vec4 &v) |
Adds the given vector to this vector. More... | |
const Vec4 | operator- (const Vec4 &v) const |
Calculates the sum of this vector with the given vector. More... | |
Vec4 & | operator-= (const Vec4 &v) |
Subtracts the given vector from this vector. More... | |
const Vec4 | operator- () const |
Calculates the negation of this vector. More... | |
const Vec4 | operator* (float s) const |
Calculates the scalar product of this vector with the given value. More... | |
Vec4 & | operator*= (float s) |
Scales this vector by the given value. More... | |
const Vec4 | operator/ (float s) const |
Returns the components of this vector divided by the given constant. More... | |
bool | operator< (const Vec4 &v) const |
Determines if this vector is less than the given vector. More... | |
bool | operator== (const Vec4 &v) const |
Determines if this vector is equal to the given vector. More... | |
bool | operator!= (const Vec4 &v) const |
Determines if this vector is not equal to the given vector. More... | |
Static Public Member Functions | |
static Vec4 | fromColor (unsigned int color) |
Creates a new vector from an integer interpreted as an RGBA value. More... | |
static float | angle (const Vec4 &v1, const Vec4 &v2) |
Returns the angle (in radians) between the specified vectors. More... | |
static void | add (const Vec4 &v1, const Vec4 &v2, Vec4 *dst) |
Adds the specified vectors and stores the result in dst. More... | |
static void | clamp (const Vec4 &v, const Vec4 &min, const Vec4 &max, Vec4 *dst) |
Clamps the specified vector within the specified range and returns it in dst. More... | |
static float | dot (const Vec4 &v1, const Vec4 &v2) |
Returns the dot product between the specified vectors. More... | |
static void | subtract (const Vec4 &v1, const Vec4 &v2, Vec4 *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... | |
float | z |
The z-coordinate. More... | |
float | w |
The w-coordinate. More... | |
Static Public Attributes | |
static const Vec4 | ZERO |
equals to Vec4(0,0,0,0) More... | |
static const Vec4 | ONE |
equals to Vec4(1,1,1,1) More... | |
static const Vec4 | UNIT_X |
equals to Vec4(1,0,0,0) More... | |
static const Vec4 | UNIT_Y |
equals to Vec4(0,1,0,0) More... | |
static const Vec4 | UNIT_Z |
equals to Vec4(0,0,1,0) More... | |
static const Vec4 | UNIT_W |
equals to Vec4(0,0,0,1) More... | |
Defines 4-element floating point vector.
Vec4 | ( | ) |
Constructs a new vector initialized to all zeros.
Vec4 | ( | float | xx, |
float | yy, | ||
float | zz, | ||
float | ww | ||
) |
Constructs a new vector initialized to the specified values.
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.
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.
p1 | The first point. |
p2 | The second point. |
Constructor.
Creates a new vector that is a copy of the specified vector.
copy | The vector to copy. |
~Vec4 | ( | ) |
Destructor.
void add | ( | const Vec4 & | v | ) |
Adds the elements of the specified vector to this one.
v | The vector to add. |
Adds the specified vectors and stores the result in dst.
v1 | The first vector. |
v2 | The second vector. |
dst | A vector to store the result in. |
Returns the angle (in radians) between the specified vectors.
v1 | The first vector. |
v2 | The second vector. |
Clamps this vector within the specified range.
min | The minimum value. |
max | The maximum value. |
Clamps the specified vector within the specified range and returns it in dst.
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.
v | The other vector. |
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.
v | The other vector. |
float dot | ( | const Vec4 & | v | ) | const |
Returns the dot product of this vector and the specified vector.
v | The vector to compute the dot product with. |
Returns the dot product between the specified vectors.
v1 | The first vector. |
v2 | The second vector. |
|
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).
color | The integer to interpret as an RGBA value. |
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.
dst | The destination vector. |
bool isOne | ( | ) | const |
Indicates whether this vector contains all ones.
bool isZero | ( | ) | const |
Indicates whether this vector contains all zeros.
float length | ( | ) | const |
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.
void negate | ( | ) |
Negates this vector.
void normalize | ( | ) |
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.
|
inline |
Determines if this vector is not equal to the given vector.
v | The vector to compare against. |
|
inline |
Calculates the scalar product of this vector with the given value.
Note: this does not modify this vector.
s | The value to scale by. |
|
inline |
Scales this vector by the given value.
s | The value to scale by. |
Calculates the sum of this vector with the given vector.
Note: this does not modify this vector.
v | The vector to add. |
Adds the given vector to this vector.
v | The vector to add. |
Calculates the sum of this vector with the given vector.
Note: this does not modify this vector.
v | The vector to add. |
|
inline |
Calculates the negation of this vector.
Note: this does not modify this vector.
Subtracts the given vector from this vector.
v | The vector to subtract. |
|
inline |
Returns the components of this vector divided by the given constant.
Note: this does not modify this vector.
s | the constant to divide this vector with |
|
inline |
Determines if this vector is less than the given vector.
v | The vector to compare against. |
|
inline |
Determines if this vector is equal to the given vector.
v | The vector to compare against. |
void scale | ( | float | scalar | ) |
Scales all elements of this vector by the specified value.
scalar | The scalar value. |
void set | ( | float | xx, |
float | yy, | ||
float | zz, | ||
float | ww | ||
) |
Sets the elements of this vector to the specified values.
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.
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.
v | The vector to copy. |
Sets this vector to the directional vector between the specified points.
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.
v | The vector to subtract. |
Subtracts the specified vectors and stores the result in dst.
The resulting vector is computed as (v1 - v2).
v1 | The first vector. |
v2 | The second vector. |
dst | The destination vector. |
|
static |
equals to Vec4(1,1,1,1)
|
static |
equals to Vec4(0,0,0,1)
|
static |
equals to Vec4(1,0,0,0)
|
static |
equals to Vec4(0,1,0,0)
|
static |
equals to Vec4(0,0,1,0)
float w |
The w-coordinate.
float x |
The x-coordinate.
float y |
The y-coordinate.
float z |
The z-coordinate.
|
static |
equals to Vec4(0,0,0,0)