Tizen Native API
3.0
|
A four dimensional vector. More...
Public Member Functions | |
Vector4 () | |
Default constructor, initializes the vector to 0. | |
Vector4 (float x, float y, float z, float w) | |
Conversion constructor from four floats. | |
Vector4 (const float *array) | |
Conversion constructor from an array of four floats. | |
Vector4 (const Vector2 &vec2) | |
Conversion constructor from Vector2. | |
Vector4 (const Vector3 &vec3) | |
Conversion constructor from Vector3. | |
Vector4 & | operator= (const float *array) |
Assignment operator. | |
Vector4 & | operator= (const Vector2 &vec2) |
Assignment operator. | |
Vector4 & | operator= (const Vector3 &vec3) |
Assignment operator. | |
Vector4 | operator+ (const Vector4 &rhs) const |
Addition operator. | |
Vector4 & | operator+= (const Vector4 &rhs) |
Addition assignment operator. | |
Vector4 | operator- (const Vector4 &rhs) const |
Subtraction operator. | |
Vector4 & | operator-= (const Vector4 &rhs) |
Subtraction assignment operator. | |
Vector4 | operator* (const Vector4 &rhs) const |
Multiplication operator. | |
Vector4 | operator* (float rhs) const |
Multiplication operator. | |
Vector4 & | operator*= (const Vector4 &rhs) |
Multiplication assignment operator. | |
Vector4 & | operator*= (float rhs) |
Multiplication assignment operator. | |
Vector4 | operator/ (const Vector4 &rhs) const |
Division operator. | |
Vector4 | operator/ (float rhs) const |
Division operator. | |
Vector4 & | operator/= (const Vector4 &rhs) |
Division assignment operator. | |
Vector4 & | operator/= (float rhs) |
Division assignment operator. | |
Vector4 | operator- () const |
Unary negation operator. | |
bool | operator== (const Vector4 &rhs) const |
Equality operator. | |
bool | operator!= (const Vector4 &rhs) const |
Inequality operator. | |
const float & | operator[] (const unsigned int index) const |
Const array subscript operator overload. | |
float & | operator[] (const unsigned int index) |
Mutable array subscript operator overload. | |
float | Dot (const Vector3 &other) const |
Returns the dot product of this vector (4d) and another vector (3d). | |
float | Dot (const Vector4 &other) const |
Returns the dot product of this vector and another vector. | |
float | Dot4 (const Vector4 &other) const |
Returns the 4d dot product of this vector and another vector. | |
Vector4 | Cross (const Vector4 &other) const |
Returns the cross produce of this vector and another vector. | |
float | Length () const |
Returns the length of the vector. | |
float | LengthSquared () const |
Returns the length of the vector squared. | |
void | Normalize () |
Normalizes the vector. | |
void | Clamp (const Vector4 &min, const Vector4 &max) |
Clamps the vector between minimum and maximum vectors. | |
const float * | AsFloat () const |
Returns the contents of the vector as an array of 4 floats. | |
float * | AsFloat () |
Returns the contents of the vector as an array of 4 floats. | |
Static Public Attributes | |
static const Vector4 | ONE |
(1.0f,1.0f,1.0f,1.0f) | |
static const Vector4 | XAXIS |
(1.0f,0.0f,0.0f,0.0f) | |
static const Vector4 | YAXIS |
(0.0f,1.0f,0.0f,0.0f) | |
static const Vector4 | ZAXIS |
(0.0f,0.0f,1.0f,0.0f) | |
static const Vector4 | ZERO |
(0.0f, 0.0f, 0.0f, 0.0f) |
Detailed Description
A four dimensional vector.
Components can be used as position or offset (x,y,z,w); color (r,g,b,a) or texture coords(s,t,p,q).
- Since:
- 3.0, DALi version 1.0.0
Constructor & Destructor Documentation
Default constructor, initializes the vector to 0.
- Since:
- 3.0, DALi version 1.0.0
Dali::Vector4::Vector4 | ( | float | x, |
float | y, | ||
float | z, | ||
float | w | ||
) | [explicit] |
Conversion constructor from four floats.
- Since:
- 3.0, DALi version 1.0.0
- Parameters:
-
[in] x x (or r/s) component [in] y y (or g/t) component [in] z z (or b/p) component [in] w w (or a/q) component
Dali::Vector4::Vector4 | ( | const float * | array | ) | [explicit] |
Conversion constructor from an array of four floats.
- Since:
- 3.0, DALi version 1.0.0
- Parameters:
-
[in] array Array of either xyzw/rgba/stpq
Dali::Vector4::Vector4 | ( | const Vector2 & | vec2 | ) | [explicit] |
Dali::Vector4::Vector4 | ( | const Vector3 & | vec3 | ) | [explicit] |
Member Function Documentation
const float* Dali::Vector4::AsFloat | ( | ) | const |
Returns the contents of the vector as an array of 4 floats.
The order of the values in this array are as follows: 0: x (or r, or s) 1: y (or g, or t) 2: z (or b, or p) 3: w (or a, or q)
- Since:
- 3.0, DALi version 1.0.0
- Returns:
- The vector contents as an array of 4 floats
- Note:
- inlined for performance reasons (generates less code than a function call)
float* Dali::Vector4::AsFloat | ( | ) |
Returns the contents of the vector as an array of 4 floats.
The order of the values in this array are as follows: 0: x (or r, or s) 1: y (or g, or t) 2: z (or b, or p) 3: w (or a, or q)
- Since:
- 3.0, DALi version 1.0.0
- Returns:
- The vector contents as an array of 4 floats
- Note:
- inlined for performance reasons (generates less code than a function call)
void Dali::Vector4::Clamp | ( | const Vector4 & | min, |
const Vector4 & | max | ||
) |
Clamps the vector between minimum and maximum vectors.
- Since:
- 3.0, DALi version 1.0.0
- Parameters:
-
[in] min The minimum vector [in] max The maximum vector
Vector4 Dali::Vector4::Cross | ( | const Vector4 & | other | ) | const |
Returns the cross produce of this vector and another vector.
The cross produce of two vectors is a vector which is perpendicular to the plane of the two vectors. This is great for calculating normals and making matrices orthogonal.
- Since:
- 3.0, DALi version 1.0.0
- Parameters:
-
[in] other The other vector
- Returns:
- A vector containing the cross product
float Dali::Vector4::Dot | ( | const Vector3 & | other | ) | const |
Returns the dot product of this vector (4d) and another vector (3d).
The dot product is the length of one vector in the direction of another vector. This is great for lighting, threshold testing the angle between two unit vectors, calculating the distance between two points in a particular direction.
- Since:
- 3.0, DALi version 1.0.0
- Parameters:
-
[in] other The other vector
- Returns:
- The dot product
float Dali::Vector4::Dot | ( | const Vector4 & | other | ) | const |
Returns the dot product of this vector and another vector.
The dot product is the length of one vector in the direction of another vector. This is great for lighting, threshold testing the angle between two unit vectors, calculating the distance between two points in a particular direction.
- Since:
- 3.0, DALi version 1.0.0
- Parameters:
-
[in] other The other vector
- Returns:
- The dot product
float Dali::Vector4::Dot4 | ( | const Vector4 & | other | ) | const |
Returns the 4d dot product of this vector and another vector.
- Since:
- 3.0, DALi version 1.0.0
- Parameters:
-
[in] other The other vector
- Returns:
- The dot product
float Dali::Vector4::Length | ( | ) | const |
Returns the length of the vector.
- Since:
- 3.0, DALi version 1.0.0
- Returns:
- The length
float Dali::Vector4::LengthSquared | ( | ) | const |
Returns the length of the vector squared.
This is faster than using Length() when performing threshold checks as it avoids use of the square root.
- Since:
- 3.0, DALi version 1.0.0
- Returns:
- The length of the vector squared
void Dali::Vector4::Normalize | ( | ) |
Normalizes the vector.
Sets the vector to unit length whilst maintaining its direction.
- Since:
- 3.0, DALi version 1.0.0
bool Dali::Vector4::operator!= | ( | const Vector4 & | rhs | ) | const |
Inequality operator.
Utilizes appropriate machine epsilon values.
- Since:
- 3.0, DALi version 1.0.0
- Parameters:
-
[in] rhs The vector to test against
- Returns:
- True if the vectors are not equal
Multiplication operator.
- Since:
- 3.0, DALi version 1.0.0
- Parameters:
-
[in] rhs The vector to multiply
- Returns:
- A vector containing the result of the multiplication
Vector4 Dali::Vector4::operator* | ( | float | rhs | ) | const |
Multiplication operator.
- Since:
- 3.0, DALi version 1.0.0
- Parameters:
-
[in] rhs The float value to scale the vector
- Returns:
- A vector containing the result of the scaling
Multiplication assignment operator.
- Since:
- 3.0, DALi version 1.0.0
- Parameters:
-
[in] rhs The vector to multiply
- Returns:
- Itself
Vector4& Dali::Vector4::operator*= | ( | float | rhs | ) |
Multiplication assignment operator.
- Since:
- 3.0, DALi version 1.0.0
- Parameters:
-
[in] rhs The float value to scale the vector
- Returns:
- Itself
Addition operator.
- Since:
- 3.0, DALi version 1.0.0
- Parameters:
-
[in] rhs Vector to add
- Returns:
- A vector containing the result of the addition
Addition assignment operator.
- Since:
- 3.0, DALi version 1.0.0
- Parameters:
-
[in] rhs Vector to add
- Returns:
- Itself
Subtraction operator.
- Since:
- 3.0, DALi version 1.0.0
- Parameters:
-
[in] rhs The vector to subtract
- Returns:
- A vector containing the result of the subtraction
Vector4 Dali::Vector4::operator- | ( | ) | const |
Unary negation operator.
- Since:
- 3.0, DALi version 1.0.0
- Returns:
- The negative value
Subtraction assignment operator.
- Since:
- 3.0, DALi version 1.0.0
- Parameters:
-
[in] rhs The vector to subtract
- Returns:
- Itself
Division operator.
- Since:
- 3.0, DALi version 1.0.0
- Parameters:
-
[in] rhs The vector to divide
- Returns:
- A vector containing the result of the division
Vector4 Dali::Vector4::operator/ | ( | float | rhs | ) | const |
Division operator.
- Since:
- 3.0, DALi version 1.0.0
- Parameters:
-
[in] rhs The float value to scale the vector by
- Returns:
- A vector containing the result of the scaling
Division assignment operator.
- Since:
- 3.0, DALi version 1.0.0
- Parameters:
-
[in] rhs The vector to divide
- Returns:
- Itself
Vector4& Dali::Vector4::operator/= | ( | float | rhs | ) |
Division assignment operator.
- Since:
- 3.0, DALi version 1.0.0
- Parameters:
-
[in] rhs The float value to scale the vector by
- Returns:
- Itself
Vector4& Dali::Vector4::operator= | ( | const float * | array | ) |
Assignment operator.
- Since:
- 3.0, DALi version 1.0.0
- Parameters:
-
[in] array Array of floats
- Returns:
- Itself
Assignment operator.
Only sets x and y. z and w are left as they were.
- Since:
- 3.0, DALi version 1.0.0
- Parameters:
-
[in] vec2 A reference to assign from
- Returns:
- Itself
Assignment operator.
Only sets x and y and z. w is left as it was.
- Since:
- 3.0, DALi version 1.0.0
- Parameters:
-
[in] vec3 A reference to assign from
- Returns:
- Itself
bool Dali::Vector4::operator== | ( | const Vector4 & | rhs | ) | const |
Equality operator.
Utilizes appropriate machine epsilon values.
- Since:
- 3.0, DALi version 1.0.0
- Parameters:
-
[in] rhs The vector to test against
- Returns:
- True if the vectors are equal
const float& Dali::Vector4::operator[] | ( | const unsigned int | index | ) | const |
Const array subscript operator overload.
Asserts if index is out of range. Should be 0, 1, 2 or 3.
- Since:
- 3.0, DALi version 1.0.0
- Parameters:
-
[in] index Subscript index
- Returns:
- The float at the given index
float& Dali::Vector4::operator[] | ( | const unsigned int | index | ) |
Mutable array subscript operator overload.
Asserts if index is out of range. Should be 0, 1, 2 or 3.
- Since:
- 3.0, DALi version 1.0.0
- Parameters:
-
[in] index Subscript index
- Returns:
- The float at the given index