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) const
Get the distance between this vector and another.
Parameters:
other
The other vector
Returns:
the distance
distanceSquared
T distanceSquared(const Vector<T> &other) const
Get the squared distance between this vector and another.
Parameters:
other
The other vector
Returns:
the distance
getX
T getX() const
Gets the X component.
Returns:
The X component.
getY
T getY() const
Gets the Y component.
Returns:
The Y component.
getZ
T getZ() const
Gets the Z component.
Returns:
The Z component.
length
T length() const
Gets the magnitude of the vector, defined as sqrt(x^2+y^2+z^2).
Returns:
the magnitude
lengthSquared
T lengthSquared() const
Gets 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:
x
The new X component.
Returns:
This vector.
setY
void setY(T y)
Set the Y component.
Parameters:
y
The new Y component.
Returns:
This vector.
setZ
void setZ(T z)
Set the Z component.
Parameters:
z
The new Z component.
Returns:
This vector.