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

#include <Vector3.h>

Collaboration diagram for Vector3< T >:
Collaboration graph
[legend]

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...
 
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 (T a_X, T a_Y, T a_Z)
 
void Move (const Vector3< T > &a_Diff)
 
void Normalize (void)
 
Vector3< T > NormalizeCopy (void) const
 
void NormalizeCopy (Vector3< T > &a_Rhs) const
 Sets the given vector to the normalized version of this vector. More...
 
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...
 
 Vector3 (void)
 
 Vector3 (T a_x, T a_y, T a_z)
 
template<typename U , typename = typename std::enable_if<!std::is_same<U, T>::value>::type>
 Vector3 (const Vector3< U > &a_Rhs)
 

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...
 

Friends

template<typename ArgFormatter >
void format_arg (fmt::BasicFormatter< char, ArgFormatter > &a_Formatter, const char *&a_FormatStr, Vector3 a_Vec)
 Allows formatting a Vector<T> using the same format specifiers as for T e.g. More...
 

Detailed Description

template<typename T>
class Vector3< T >

Definition at line 10 of file Vector3.h.

Constructor & Destructor Documentation

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

Definition at line 20 of file Vector3.h.

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

Definition at line 21 of file Vector3.h.

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

Definition at line 34 of file Vector3.h.

Member Function Documentation

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

Updates each coord to its absolute value.

Definition at line 111 of file Vector3.h.

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 293 of file Vector3.h.

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 311 of file Vector3.h.

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 299 of file Vector3.h.

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 305 of file Vector3.h.

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

Clamps each coord into the specified range.

Definition at line 119 of file Vector3.h.

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

Definition at line 126 of file Vector3.h.

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

Definition at line 105 of file Vector3.h.

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

Definition at line 135 of file Vector3.h.

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

Definition at line 152 of file Vector3.h.

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 172 of file Vector3.h.

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

Definition at line 81 of file Vector3.h.

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

Definition at line 95 of file Vector3.h.

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 321 of file Vector3.h.

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 336 of file Vector3.h.

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 351 of file Vector3.h.

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

Definition at line 157 of file Vector3.h.

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

Definition at line 164 of file Vector3.h.

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

Definition at line 44 of file Vector3.h.

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

Definition at line 53 of file Vector3.h.

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 68 of file Vector3.h.

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

Definition at line 183 of file Vector3.h.

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

Definition at line 256 of file Vector3.h.

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

Definition at line 274 of file Vector3.h.

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

Definition at line 217 of file Vector3.h.

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

Definition at line 224 of file Vector3.h.

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

Definition at line 233 of file Vector3.h.

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

Definition at line 203 of file Vector3.h.

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

Definition at line 242 of file Vector3.h.

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

Definition at line 251 of file Vector3.h.

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

Definition at line 210 of file Vector3.h.

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

Definition at line 265 of file Vector3.h.

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

Definition at line 283 of file Vector3.h.

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

Definition at line 198 of file Vector3.h.

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

Definition at line 188 of file Vector3.h.

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

Definition at line 193 of file Vector3.h.

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

Definition at line 37 of file Vector3.h.

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

Definition at line 100 of file Vector3.h.

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 371 of file Vector3.h.

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 363 of file Vector3.h.

Friends And Related Function Documentation

template<typename T>
template<typename ArgFormatter >
void format_arg ( fmt::BasicFormatter< char, ArgFormatter > &  a_Formatter,
const char *&  a_FormatStr,
Vector3< T >  a_Vec 
)
friend

Allows formatting a Vector<T> using the same format specifiers as for T e.g.

fmt::format("{0:0.2f}", Vector3f{0.0231f, 1.2146f, 1.0f}) == "{0.02, 1.21, 1.00}"

Definition at line 382 of file Vector3.h.

Member Data Documentation

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 394 of file Vector3.h.

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 397 of file Vector3.h.

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

Definition at line 17 of file Vector3.h.

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

Definition at line 17 of file Vector3.h.

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: