Class endstone::Vector¶
Represents a 3-dimensional vector.
- #include <endstone/util/vector.h>
Inherited by the following classes: endstone::Location
Public Functions¶
| Type | Name | 
|---|---|
| constexpr | Vector () = default Construct the vector with all components as 0. | 
| constexpr | Vector (T x, T y, T z) Construct the vector with provided components. | 
| float | distance (const Vector & other) const | 
| constexpr float | distanceSquared (const Vector & other) const | 
| constexpr float | getX () const Gets the X component. | 
| constexpr float | getY () const Gets the Y component. | 
| constexpr float | getZ () const Gets the Z component. | 
| float | length () const Gets the magnitude of the vector, defined as sqrt(x2+y2+z^2). | 
| constexpr float | lengthSquared () const Gets the magnitude of the vector squared. | 
| Vector & | normalize () | 
| constexpr Vector | operator* (const Vector & other) const | 
| Vector | operator* (float scalar) const | 
| Vector & | operator*= (const Vector & other) | 
| constexpr Vector | operator+ (const Vector & other) const | 
| Vector | operator+ (float scalar) const | 
| Vector & | operator+= (const Vector & other) | 
| constexpr Vector | operator- (const Vector & other) const | 
| Vector | operator- (float scalar) const | 
| Vector & | operator-= (const Vector & other) | 
| constexpr Vector | operator/ (const Vector & other) const | 
| Vector | operator/ (float scalar) const | 
| Vector & | operator/= (const Vector & other) | 
| constexpr bool | operator== (const Vector & other) const | 
| constexpr void | setX (float x) Set the X component. | 
| constexpr void | setY (float y) Set the Y component. | 
| constexpr void | setZ (float z) Set the Z component. | 
Protected Attributes¶
| Type | Name | 
|---|---|
| float | x_   = 0.0 | 
| float | y_   = 0.0 | 
| float | z_   = 0.0 | 
Public Functions Documentation¶
function Vector [½]¶
Construct the vector with all components as 0.
function Vector [2/2]¶
Construct the vector with provided components.
Parameters:
- xX component
- yY component
- zZ component
function distance¶
Get the distance between this vector and another.
Parameters:
- otherThe other vector
Returns:
the distance
function distanceSquared¶
Get the squared distance between this vector and another.
Parameters:
- otherThe other vector
Returns:
the distance
function getX¶
Gets the X component.
Returns:
The X component.
function getY¶
Gets the Y component.
Returns:
The Y component.
function getZ¶
Gets the Z component.
Returns:
The Z component.
function length¶
Gets the magnitude of the vector, defined as sqrt(x2+y2+z^2).
Returns:
the magnitude
function lengthSquared¶
Gets the magnitude of the vector squared.
Returns:
the magnitude
function normalize¶
Converts this vector to a unit vector (a vector with length of 1).
Returns:
the same vector
function operator*¶
function operator*¶
function operator*=¶
function operator+¶
function operator+¶
function operator+=¶
function operator-¶
function operator-¶
function operator-=¶
function operator/¶
function operator/¶
function operator/=¶
function operator==¶
function setX¶
Set the X component.
Parameters:
- xThe new X component.
Returns:
This vector.
function setY¶
Set the Y component.
Parameters:
- yThe new Y component.
Returns:
This vector.
function setZ¶
Set the Z component.
Parameters:
- zThe new Z component.
Returns:
This vector.
Protected Attributes Documentation¶
variable x_¶
variable y_¶
variable z_¶
Friends Documentation¶
friend operator*¶
friend operator+¶
friend operator-¶
friend operator/¶
The documentation for this class was generated from the following file include/endstone/util/vector.h