Cuberite
A lightweight, fast and extensible game server for Minecraft
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
Vector3< T > Class Template Reference

#include <Vector3.h>

Public Member Functions

void Abs ()
 Updates each coord to its absolute value. More...
 
Vector3< T > addedX (T a_AddX) const
 Returns a copy of this vector moved by the specified amount on the X axis. More...
 
Vector3< T > addedXZ (T a_AddX, T a_AddZ) const
 Returns a copy of this vector moved by the specified amount on the X and Z axes. More...
 
Vector3< T > addedY (T a_AddY) const
 Returns a copy of this vector moved by the specified amount on the y axis. More...
 
Vector3< T > addedZ (T a_AddZ) const
 Returns a copy of this vector moved by the specified amount on the Z axis. More...
 
Vector3< int > Ceil () const
 Returns a new Vector3i with coords set to std::ceil() of this vector's coords. More...
 
void Clamp (T a_Min, T a_Max)
 Clamps each coord into the specified range. More...
 
Vector3< T > Cross (const Vector3< T > &a_Rhs) const
 
Dot (const Vector3< T > &a_Rhs) const
 
bool Equals (const Vector3< T > &a_Rhs) const
 
bool EqualsEps (const Vector3< T > &a_Rhs, T a_Eps) const
 
Vector3< int > Floor (void) const
 Returns a new Vector3i with coords set to std::floor() of this vector's coords. More...
 
bool HasNonZeroLength (void) const
 
double Length (void) const
 
double LineCoeffToXYPlane (const Vector3< T > &a_OtherEnd, T a_Z) const
 Returns the coefficient for the (a_OtherEnd - this) line to reach the specified Z coord. More...
 
double LineCoeffToXZPlane (const Vector3< T > &a_OtherEnd, T a_Y) const
 Returns the coefficient for the (a_OtherEnd - this) line to reach the specified Y coord. More...
 
double LineCoeffToYZPlane (const Vector3< T > &a_OtherEnd, T a_X) const
 Returns the coefficient for the (a_OtherEnd - this) line to reach the specified X coord. More...
 
void Move (const Vector3< T > &a_Diff)
 
void Move (T a_X, T a_Y, T a_Z)
 
void Normalize (void)
 
void NormalizeCopy (Vector3< T > &a_Rhs) const
 Sets the given vector to the normalized version of this vector. More...
 
Vector3< T > NormalizeCopy (void) const
 
bool operator!= (const Vector3< T > &a_Rhs) const
 
Vector3< T > operator* (const Vector3< T > &a_Rhs) const
 
Vector3< T > operator* (T a_v) const
 
void operator*= (const Vector3< T > &a_Rhs)
 
void operator*= (T a_v)
 
Vector3< T > operator+ (const Vector3< T > &a_Rhs) const
 
void operator+= (const Vector3< T > &a_Rhs)
 
Vector3< T > operator- (const Vector3< T > &a_Rhs) const
 
Vector3< T > operator- (void) const
 
void operator-= (const Vector3< T > &a_Rhs)
 
Vector3< T > operator/ (const Vector3< T > &a_Rhs)
 
Vector3< T > operator/ (T a_v) const
 
bool operator< (const Vector3< T > &a_Rhs) const
 
bool operator== (const Vector3< T > &a_Rhs) const
 
bool operator> (const Vector3< T > &a_Rhs) const
 
void Set (T a_x, T a_y, T a_z)
 
double SqrLength (void) const
 
void TurnCCW (void)
 Rotates the vector 90 degrees counterclockwise around the vertical axis. More...
 
void TurnCW (void)
 Rotates the vector 90 degrees clockwise around the vertical axis. More...
 
template<typename U , typename = typename std::enable_if<!std::is_same<U, T>::value>::type>
constexpr Vector3 (const Vector3< U > &a_Rhs)
 
constexpr Vector3 (T a_x, T a_y, T a_z)
 
constexpr Vector3 (void)
 

Public Attributes

x
 
y
 
z
 

Static Public Attributes

static const double EPS = 0.000001
 The max difference between two coords for which the coords are assumed equal. More...
 
static const double NO_INTERSECTION = 1e70
 Return value of LineCoeffToPlane() if the line is parallel to the plane. More...
 

Detailed Description

template<typename T>
class Vector3< T >

Definition at line 10 of file Vector3.h.

Constructor & Destructor Documentation

◆ Vector3() [1/3]

template<typename T >
constexpr Vector3< T >::Vector3 ( void  )
inlineconstexpr

Definition at line 20 of file Vector3.h.

◆ Vector3() [2/3]

template<typename T >
constexpr Vector3< T >::Vector3 ( a_x,
a_y,
a_z 
)
inlineconstexpr

Definition at line 21 of file Vector3.h.

◆ Vector3() [3/3]

template<typename T >
template<typename U , typename = typename std::enable_if<!std::is_same<U, T>::value>::type>
constexpr Vector3< T >::Vector3 ( const Vector3< U > &  a_Rhs)
inlineconstexpr

Definition at line 34 of file Vector3.h.

Member Function Documentation

◆ Abs()

template<typename T >
void Vector3< T >::Abs ( )
inline

Updates each coord to its absolute value.

Definition at line 116 of file Vector3.h.

◆ addedX()

template<typename T >
Vector3<T> Vector3< T >::addedX ( a_AddX) const
inline

Returns a copy of this vector moved by the specified amount on the X axis.

Definition at line 308 of file Vector3.h.

◆ addedXZ()

template<typename T >
Vector3<T> Vector3< T >::addedXZ ( a_AddX,
a_AddZ 
) const
inline

Returns a copy of this vector moved by the specified amount on the X and Z axes.

Definition at line 326 of file Vector3.h.

◆ addedY()

template<typename T >
Vector3<T> Vector3< T >::addedY ( a_AddY) const
inline

Returns a copy of this vector moved by the specified amount on the y axis.

Definition at line 314 of file Vector3.h.

◆ addedZ()

template<typename T >
Vector3<T> Vector3< T >::addedZ ( a_AddZ) const
inline

Returns a copy of this vector moved by the specified amount on the Z axis.

Definition at line 320 of file Vector3.h.

◆ Ceil()

template<typename T >
Vector3<int> Vector3< T >::Ceil ( ) const
inline

Returns a new Vector3i with coords set to std::ceil() of this vector's coords.

Definition at line 187 of file Vector3.h.

◆ Clamp()

template<typename T >
void Vector3< T >::Clamp ( a_Min,
a_Max 
)
inline

Clamps each coord into the specified range.

Definition at line 124 of file Vector3.h.

◆ Cross()

template<typename T >
Vector3<T> Vector3< T >::Cross ( const Vector3< T > &  a_Rhs) const
inline

Definition at line 131 of file Vector3.h.

◆ Dot()

template<typename T >
T Vector3< T >::Dot ( const Vector3< T > &  a_Rhs) const
inline

Definition at line 110 of file Vector3.h.

◆ Equals()

template<typename T >
bool Vector3< T >::Equals ( const Vector3< T > &  a_Rhs) const
inline

Definition at line 140 of file Vector3.h.

◆ EqualsEps()

template<typename T >
bool Vector3< T >::EqualsEps ( const Vector3< T > &  a_Rhs,
a_Eps 
) const
inline

Definition at line 157 of file Vector3.h.

◆ Floor()

template<typename T >
Vector3<int> Vector3< T >::Floor ( void  ) const
inline

Returns a new Vector3i with coords set to std::floor() of this vector's coords.

Definition at line 177 of file Vector3.h.

◆ HasNonZeroLength()

template<typename T >
bool Vector3< T >::HasNonZeroLength ( void  ) const
inline

Definition at line 86 of file Vector3.h.

◆ Length()

template<typename T >
double Vector3< T >::Length ( void  ) const
inline

Definition at line 100 of file Vector3.h.

◆ LineCoeffToXYPlane()

template<typename T >
double Vector3< T >::LineCoeffToXYPlane ( const Vector3< T > &  a_OtherEnd,
a_Z 
) const
inline

Returns the coefficient for the (a_OtherEnd - this) line to reach the specified Z coord.

The result satisfies the following equation: (*this + Result * (a_OtherEnd - *this)).z = a_Z If the line is too close to being parallel, this function returns NO_INTERSECTION

Definition at line 336 of file Vector3.h.

◆ LineCoeffToXZPlane()

template<typename T >
double Vector3< T >::LineCoeffToXZPlane ( const Vector3< T > &  a_OtherEnd,
a_Y 
) const
inline

Returns the coefficient for the (a_OtherEnd - this) line to reach the specified Y coord.

The result satisfies the following equation: (*this + Result * (a_OtherEnd - *this)).y = a_Y If the line is too close to being parallel, this function returns NO_INTERSECTION

Definition at line 351 of file Vector3.h.

◆ LineCoeffToYZPlane()

template<typename T >
double Vector3< T >::LineCoeffToYZPlane ( const Vector3< T > &  a_OtherEnd,
a_X 
) const
inline

Returns the coefficient for the (a_OtherEnd - this) line to reach the specified X coord.

The result satisfies the following equation: (*this + Result * (a_OtherEnd - *this)).x = a_X If the line is too close to being parallel, this function returns NO_INTERSECTION

Definition at line 366 of file Vector3.h.

◆ Move() [1/2]

template<typename T >
void Vector3< T >::Move ( const Vector3< T > &  a_Diff)
inline

Definition at line 169 of file Vector3.h.

◆ Move() [2/2]

template<typename T >
void Vector3< T >::Move ( a_X,
a_Y,
a_Z 
)
inline

Definition at line 162 of file Vector3.h.

◆ Normalize()

template<typename T >
void Vector3< T >::Normalize ( void  )
inline

Definition at line 49 of file Vector3.h.

◆ NormalizeCopy() [1/2]

template<typename T >
void Vector3< T >::NormalizeCopy ( Vector3< T > &  a_Rhs) const
inline

Sets the given vector to the normalized version of this vector.

Removed from LuaAPI, because Lua doesn't need distinguishing from the other overload.

Definition at line 73 of file Vector3.h.

◆ NormalizeCopy() [2/2]

template<typename T >
Vector3<T> Vector3< T >::NormalizeCopy ( void  ) const
inline

Definition at line 58 of file Vector3.h.

◆ operator!=()

template<typename T >
bool Vector3< T >::operator!= ( const Vector3< T > &  a_Rhs) const
inline

Definition at line 198 of file Vector3.h.

◆ operator*() [1/2]

template<typename T >
Vector3<T> Vector3< T >::operator* ( const Vector3< T > &  a_Rhs) const
inline

Definition at line 271 of file Vector3.h.

◆ operator*() [2/2]

template<typename T >
Vector3<T> Vector3< T >::operator* ( a_v) const
inline

Definition at line 289 of file Vector3.h.

◆ operator*=() [1/2]

template<typename T >
void Vector3< T >::operator*= ( const Vector3< T > &  a_Rhs)
inline

Definition at line 232 of file Vector3.h.

◆ operator*=() [2/2]

template<typename T >
void Vector3< T >::operator*= ( a_v)
inline

Definition at line 239 of file Vector3.h.

◆ operator+()

template<typename T >
Vector3<T> Vector3< T >::operator+ ( const Vector3< T > &  a_Rhs) const
inline

Definition at line 248 of file Vector3.h.

◆ operator+=()

template<typename T >
void Vector3< T >::operator+= ( const Vector3< T > &  a_Rhs)
inline

Definition at line 218 of file Vector3.h.

◆ operator-() [1/2]

template<typename T >
Vector3<T> Vector3< T >::operator- ( const Vector3< T > &  a_Rhs) const
inline

Definition at line 257 of file Vector3.h.

◆ operator-() [2/2]

template<typename T >
Vector3<T> Vector3< T >::operator- ( void  ) const
inline

Definition at line 266 of file Vector3.h.

◆ operator-=()

template<typename T >
void Vector3< T >::operator-= ( const Vector3< T > &  a_Rhs)
inline

Definition at line 225 of file Vector3.h.

◆ operator/() [1/2]

template<typename T >
Vector3<T> Vector3< T >::operator/ ( const Vector3< T > &  a_Rhs)
inline

Definition at line 280 of file Vector3.h.

◆ operator/() [2/2]

template<typename T >
Vector3<T> Vector3< T >::operator/ ( a_v) const
inline

Definition at line 298 of file Vector3.h.

◆ operator<()

template<typename T >
bool Vector3< T >::operator< ( const Vector3< T > &  a_Rhs) const
inline

Definition at line 213 of file Vector3.h.

◆ operator==()

template<typename T >
bool Vector3< T >::operator== ( const Vector3< T > &  a_Rhs) const
inline

Definition at line 203 of file Vector3.h.

◆ operator>()

template<typename T >
bool Vector3< T >::operator> ( const Vector3< T > &  a_Rhs) const
inline

Definition at line 208 of file Vector3.h.

◆ Set()

template<typename T >
void Vector3< T >::Set ( a_x,
a_y,
a_z 
)
inline

Definition at line 42 of file Vector3.h.

◆ SqrLength()

template<typename T >
double Vector3< T >::SqrLength ( void  ) const
inline

Definition at line 105 of file Vector3.h.

◆ TurnCCW()

template<typename T >
void Vector3< T >::TurnCCW ( void  )
inline

Rotates the vector 90 degrees counterclockwise around the vertical axis.

Note that this is specific to minecraft's axis ordering, which is X+ left, Z+ down.

Definition at line 386 of file Vector3.h.

◆ TurnCW()

template<typename T >
void Vector3< T >::TurnCW ( void  )
inline

Rotates the vector 90 degrees clockwise around the vertical axis.

Note that this is specific to minecraft's axis ordering, which is X+ left, Z+ down.

Definition at line 378 of file Vector3.h.

Member Data Documentation

◆ EPS

template<typename T >
const double Vector3< T >::EPS = 0.000001
static

The max difference between two coords for which the coords are assumed equal.

Definition at line 393 of file Vector3.h.

◆ NO_INTERSECTION

template<typename T >
const double Vector3< T >::NO_INTERSECTION = 1e70
static

Return value of LineCoeffToPlane() if the line is parallel to the plane.

Definition at line 396 of file Vector3.h.

◆ x

template<typename T >
T Vector3< T >::x

Definition at line 17 of file Vector3.h.

◆ y

template<typename T >
T Vector3< T >::y

Definition at line 17 of file Vector3.h.

◆ z

template<typename T >
T Vector3< T >::z

Definition at line 17 of file Vector3.h.


The documentation for this class was generated from the following file: