Vec4 - GL Math¶
PHP-GLFW comes with built in fixed size vector classes. Vec4
represents a vector with 4 components (
x
, y
, z
, w
, ).
namespace GL\Math
{
class Vec4 {
public float $x;
public float $y;
public float $z;
public float $w;
}
}
The properties of this class are virtual, meaning in this case they are not real PHP properties. But rather values stored internally that can be accessed like a property. The same values can be read and written using different names for convience:
Is exactly the same as:
Methods¶
__construct
¶
Constructor
normalized
¶
Retruns a normalized version of the given Vec4 *
- arguments
-
\Vec4
$vec
The vector to normalize.
- returns
-
\Vec4
The normalized vector.
distance
¶
Returns the distance between the left and right vectors
- arguments
-
\Vec4
$left
The left vector.\Vec4
$right
The right vector.
- returns
-
float
The distance between the left and right vectors.
distance2
¶
Returns the squared distance between the left and right vectors
- arguments
-
\Vec4
$left
The left vector.\Vec4
$right
The right vector.
- returns
-
float
The squared distance between the left and right vectors.
dot
¶
Returns the dot product of the left and right vectors
- arguments
-
\Vec4
$left
The left vector.\Vec4
$right
The right vector.
- returns
-
float
The dot product of the left and right vectors.
mix
¶
Linearly interpolates between the left and right vectors by the given t value.
- arguments
-
\Vec4
$left
The left vector.\Vec4
$right
The right vector.float
$t
The t value (progress / state) 0.0 == left, 1.0 == right.
- returns
-
\Vec4
The mixed vector.
lerp
¶
Linearly interpolates between the left and right vectors by the given t value.
This does exactly the same as mix..
- arguments
-
\Vec4
$left
The left vector.\Vec4
$right
The right vector.float
$t
The t value (progress / state) 0.0 == left, 1.0 == right.
- returns
-
\Vec4
The lerped vector.
slerp
¶
Spherically interpolates between the left and right vectors by the given t value.
- arguments
-
\Vec4
$left
The left vector.\Vec4
$right
The right vector.float
$t
The t value (progress / state) 0.0 == left, 1.0 == right.
- returns
-
\Vec4
The slerped vector.
length
¶
Returns the length of the vector
- returns
-
float
distanceTo
¶
Returns the distance between this vector and another
- returns
-
float
distance2To
¶
Returns squared distance between this vector and another
- returns
-
float
normalize
¶
normalizes the current vector
- returns
-
void
abs
¶
Makes each component x if x >= 0; otherwise, -x
- returns
-
void