Vec3 - GL Math¶
PHP-GLFW comes with built in fixed size vector classes. Vec3 represents a vector with 3 components (
x, y, z, ).
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 Vec3 *
- arguments
-
\Vec3$vecThe vector to normalize.
- returns
-
\Vec3The normalized vector.
distance¶
Returns the distance between the left and right vectors
- arguments
-
\Vec3$leftThe left vector.\Vec3$rightThe right vector.
- returns
-
floatThe distance between the left and right vectors.
distance2¶
Returns the squared distance between the left and right vectors
- arguments
-
\Vec3$leftThe left vector.\Vec3$rightThe right vector.
- returns
-
floatThe squared distance between the left and right vectors.
dot¶
Returns the dot product of the left and right vectors
- arguments
-
\Vec3$leftThe left vector.\Vec3$rightThe right vector.
- returns
-
floatThe dot product of the left and right vectors.
mix¶
Linearly interpolates between the left and right vectors by the given t value.
- arguments
-
\Vec3$leftThe left vector.\Vec3$rightThe right vector.float$tThe t value (progress / state) 0.0 == left, 1.0 == right.
- returns
-
\Vec3The mixed vector.
lerp¶
Linearly interpolates between the left and right vectors by the given t value.
This does exactly the same as mix..
- arguments
-
\Vec3$leftThe left vector.\Vec3$rightThe right vector.float$tThe t value (progress / state) 0.0 == left, 1.0 == right.
- returns
-
\Vec3The lerped vector.
slerp¶
Spherically interpolates between the left and right vectors by the given t value.
- arguments
-
\Vec3$leftThe left vector.\Vec3$rightThe right vector.float$tThe t value (progress / state) 0.0 == left, 1.0 == right.
- returns
-
\Vec3The 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