endstone::Vector
Represents a 3-dimensional vector.
template <typename T>
Functions:
| Name | Description |
|---|---|
Vector | |
Vector | |
distance | |
distanceSquared | |
getX | Gets the X component. |
getY | Gets the Y component. |
getZ | Gets the Z component. |
length | Gets the magnitude of the vector, defined as sqrt(x^2+y^2+z^2). |
lengthSquared | Gets the magnitude of the vector squared. |
normalize | |
setX | Set the X component. |
setY | Set the Y component. |
setZ | Set the Z component. |
Vector
constexpr Vector()constexpr Vector(T x, T y, T z) distance
T distance(const Vector<T> &other) constGet the distance between this vector and another.
Parameters:
otherThe other vector
Returns:
the distance
distanceSquared
T distanceSquared(const Vector<T> &other) constGet the squared distance between this vector and another.
Parameters:
otherThe other vector
Returns:
the distance
getX
T getX() constGets the X component.
Returns:
The X component.
getY
T getY() constGets the Y component.
Returns:
The Y component.
getZ
T getZ() constGets the Z component.
Returns:
The Z component.
length
T length() constGets the magnitude of the vector, defined as sqrt(x^2+y^2+z^2).
Returns:
the magnitude
lengthSquared
T lengthSquared() constGets the magnitude of the vector squared.
Returns:
the magnitude
normalize
Vector<T> &normalize()Converts this vector to a unit vector (a vector with length of 1).
Returns:
the same vector
setX
void setX(T x)Set the X component.
Parameters:
xThe new X component.
Returns:
This vector.
setY
void setY(T y)Set the Y component.
Parameters:
yThe new Y component.
Returns:
This vector.
setZ
void setZ(T z)Set the Z component.
Parameters:
zThe new Z component.
Returns:
This vector.