Skip to content

Class endstone::Vector

template <typename T>

ClassList > endstone > Vector

Represents a 3-dimensional vector.

  • #include <endstone/util/vector.h>

Public Functions

Type Name
constexpr Vector ()
constexpr Vector (T x, T y, T z)
constexpr T distance (const Vector< T > & other) const
constexpr T distanceSquared (const Vector< T > & other) const
constexpr T getX () const
Gets the X component.
constexpr T getY () const
Gets the Y component.
constexpr T getZ () const
Gets the Z component.
constexpr T length () const
Gets the magnitude of the vector, defined as sqrt(x2+y2+z^2).
constexpr T lengthSquared () const
Gets the magnitude of the vector squared.
constexpr Vector< T > operator* (const Vector< T > & other) const
Vector< T > operator* (T scalar) const
Vector< T > & operator*= (const Vector< T > & other)
constexpr Vector< T > operator+ (const Vector< T > & other) const
Vector< T > operator+ (T scalar) const
Vector< T > & operator+= (const Vector< T > & other)
constexpr Vector< T > operator- (const Vector< T > & other) const
Vector< T > operator- (T scalar) const
Vector< T > & operator-= (const Vector< T > & other)
constexpr Vector< T > operator/ (const Vector< T > & other) const
Vector< T > operator/ (T scalar) const
Vector< T > & operator/= (const Vector< T > & other)
constexpr bool operator== (const Vector< T > & other) const
constexpr void setX (T x)
Set the X component.
constexpr void setY (T y)
Set the Y component.
constexpr void setZ (T z)
Set the Z component.

Protected Attributes

Type Name
T x_
T y_
T z_

Public Functions Documentation

function Vector [½]

inline constexpr endstone::Vector::Vector () 

function Vector [2/2]

inline constexpr endstone::Vector::Vector (
    T x,
    T y,
    T z
) 

function distance

inline constexpr T endstone::Vector::distance (
    const Vector < T > & other
) const

Get the distance between this vector and another.

Parameters:

  • other The other vector

Returns:

the distance


function distanceSquared

inline constexpr T endstone::Vector::distanceSquared (
    const Vector < T > & other
) const

Get the squared distance between this vector and another.

Parameters:

  • other The other vector

Returns:

the distance


function getX

Gets the X component.

inline constexpr T endstone::Vector::getX () const

Returns:

The X component.


function getY

Gets the Y component.

inline constexpr T endstone::Vector::getY () const

Returns:

The Y component.


function getZ

Gets the Z component.

inline constexpr T endstone::Vector::getZ () const

Returns:

The Z component.


function length

Gets the magnitude of the vector, defined as sqrt(x2+y2+z^2).

inline constexpr T endstone::Vector::length () const

Returns:

the magnitude


function lengthSquared

Gets the magnitude of the vector squared.

inline constexpr T endstone::Vector::lengthSquared () const

Returns:

the magnitude


function operator*

inline constexpr Vector < T > endstone::Vector::operator* (
    const Vector < T > & other
) const

function operator*

inline Vector < T > endstone::Vector::operator* (
    T scalar
) const

function operator*=

inline Vector < T > & endstone::Vector::operator*= (
    const Vector < T > & other
) 

function operator+

inline constexpr Vector < T > endstone::Vector::operator+ (
    const Vector < T > & other
) const

function operator+

inline Vector < T > endstone::Vector::operator+ (
    T scalar
) const

function operator+=

inline Vector < T > & endstone::Vector::operator+= (
    const Vector < T > & other
) 

function operator-

inline constexpr Vector < T > endstone::Vector::operator- (
    const Vector < T > & other
) const

function operator-

inline Vector < T > endstone::Vector::operator- (
    T scalar
) const

function operator-=

inline Vector < T > & endstone::Vector::operator-= (
    const Vector < T > & other
) 

function operator/

inline constexpr Vector < T > endstone::Vector::operator/ (
    const Vector < T > & other
) const

function operator/

inline Vector < T > endstone::Vector::operator/ (
    T scalar
) const

function operator/=

inline Vector < T > & endstone::Vector::operator/= (
    const Vector < T > & other
) 

function operator==

inline constexpr bool endstone::Vector::operator== (
    const Vector < T > & other
) const

function setX

Set the X component.

inline constexpr void endstone::Vector::setX (
    T x
) 

Parameters:

  • x The new X component.

Returns:

This vector.


function setY

Set the Y component.

inline constexpr void endstone::Vector::setY (
    T y
) 

Parameters:

  • y The new Y component.

Returns:

This vector.


function setZ

Set the Z component.

inline constexpr void endstone::Vector::setZ (
    T z
) 

Parameters:

  • z The new Z component.

Returns:

This vector.


Protected Attributes Documentation

variable x_

T endstone::Vector< T >::x_;

variable y_

T endstone::Vector< T >::y_;

variable z_

T endstone::Vector< T >::z_;

Friends Documentation

friend operator*

inline Vector < T > endstone::Vector::operator* (
    T scalar,
    const Vector < T > & v
) 

friend operator+

inline Vector < T > endstone::Vector::operator+ (
    T scalar,
    const Vector < T > & v
) 

friend operator-

inline Vector < T > endstone::Vector::operator- (
    T scalar,
    const Vector < T > & v
) 

friend operator/

inline Vector < T > endstone::Vector::operator/ (
    T scalar,
    const Vector < T > & v
) 


The documentation for this class was generated from the following file include/endstone/util/vector.h