Vec2 - GL Math¶
PHP-GLFW comes with built in fixed size vector classes. Vec2
represents a vector with 2 components (
x
, y
, ).
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 Vec2 *
- arguments
-
\Vec2
$vec
The vector to normalize.
- returns
-
\Vec2
The normalized vector.
distance
¶
Returns the distance between the left and right vectors
- arguments
-
\Vec2
$left
The left vector.\Vec2
$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
-
\Vec2
$left
The left vector.\Vec2
$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
-
\Vec2
$left
The left vector.\Vec2
$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
-
\Vec2
$left
The left vector.\Vec2
$right
The right vector.float
$t
The t value (progress / state) 0.0 == left, 1.0 == right.
- returns
-
\Vec2
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
-
\Vec2
$left
The left vector.\Vec2
$right
The right vector.float
$t
The t value (progress / state) 0.0 == left, 1.0 == right.
- returns
-
\Vec2
The lerped vector.
slerp
¶
Spherically interpolates between the left and right vectors by the given t value.
- arguments
-
\Vec2
$left
The left vector.\Vec2
$right
The right vector.float
$t
The t value (progress / state) 0.0 == left, 1.0 == right.
- returns
-
\Vec2
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