Skip to Content
⚠ Under Construction
ReferenceC++ APIVector

endstone::Vector

Represents a 3-dimensional vector.

template <typename T>

Functions:

NameDescription
Vector
Vector
distance
distanceSquared
getXGets the X component.
getYGets the Y component.
getZGets the Z component.
lengthGets the magnitude of the vector, defined as sqrt(x^2+y^2+z^2).
lengthSquaredGets the magnitude of the vector squared.
normalize
setXSet the X component.
setYSet the Y component.
setZSet 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.

Last updated on