Rebel Fork Framework
Urho3D::BaseVector3< T > Class Template Reference

Three-dimensional vector with real-number values. More...

#include <Urho3D/Math/Vector3.h>

Inheritance diagram for Urho3D::BaseVector3< T >:
Urho3D::Detail::VectorTraits< T, 3 >

Public Member Functions

constexpr BaseVector3 () noexcept=default
 Construct a zero vector.
 
constexpr BaseVector3 (T x, T y, T z=T{}) noexcept
 Construct from coordinates.
 
constexpr BaseVector3 (const T data[]) noexcept
 Construct from a scalar array.
 
constexpr auto Tie () const
 Convert to tuple.
 
constexpr bool operator== (const BaseVector3 &rhs) const
 Test for equality with another vector without epsilon.
 
constexpr bool operator!= (const BaseVector3 &rhs) const
 Test for inequality with another vector without epsilon.
 
constexpr BaseVector3 operator+ (const BaseVector3 &rhs) const
 Add a vector.
 
constexpr BaseVector3 operator- () const
 Return negation.
 
constexpr BaseVector3 operator- (const BaseVector3 &rhs) const
 Subtract a vector.
 
constexpr BaseVector3 operator* (T rhs) const
 Multiply with a scalar.
 
constexpr BaseVector3 operator* (const BaseVector3 &rhs) const
 Multiply with a vector.
 
constexpr BaseVector3 operator/ (T rhs) const
 Divide by a scalar.
 
constexpr BaseVector3 operator/ (const BaseVector3 &rhs) const
 Divide by a vector.
 
constexpr BaseVector3operator+= (const BaseVector3 &rhs)
 Add-assign a vector.
 
constexpr BaseVector3operator-= (const BaseVector3 &rhs)
 Subtract-assign a vector.
 
constexpr BaseVector3operator*= (T rhs)
 Multiply-assign a scalar.
 
constexpr BaseVector3operator*= (const BaseVector3 &rhs)
 Multiply-assign a vector.
 
constexpr BaseVector3operator/= (T rhs)
 Divide-assign a scalar.
 
constexpr BaseVector3operator/= (const BaseVector3 &rhs)
 Divide-assign a vector.
 
void Normalize ()
 Normalize to unit length.
 
Length () const
 
constexpr T LengthSquared () const
 
constexpr T DotProduct (const BaseVector3 &rhs) const
 Calculate dot product.
 
AbsDotProduct (const BaseVector3 &rhs) const
 Calculate absolute dot product.
 
ProjectOntoAxis (const BaseVector3 &axis) const
 Project direction vector onto axis.
 
BaseVector3 ProjectOntoPlane (const BaseVector3 &origin, const BaseVector3 &normal) const
 Project position vector onto plane with given origin and normal.
 
ProjectOntoLineScalar (const BaseVector3 &from, const BaseVector3 &to, bool clamped=false) const
 Project position vector onto line segment. Returns interpolation factor between line points.
 
BaseVector3 ProjectOntoLine (const BaseVector3 &from, const BaseVector3 &to, bool clamped=false) const
 Project position vector onto line segment. Returns new position.
 
DistanceToPoint (const BaseVector3 &point) const
 Calculate distance to another position vector.
 
DistanceToPlane (const BaseVector3 &origin, const BaseVector3 &normal) const
 Calculate distance to the plane with given origin and normal.
 
BaseVector3 Orthogonalize (const BaseVector3 &axis) const
 Make vector orthogonal to the axis.
 
constexpr BaseVector3 CrossProduct (const BaseVector3 &rhs) const
 Calculate cross product.
 
BaseVector3 Abs () const
 Return absolute vector.
 
BaseVector3 Lerp (const BaseVector3 &rhs, T t) const
 Linear interpolation with another vector.
 
bool Equals (const BaseVector3 &rhs, T eps=static_cast< T >(M_EPSILON)) const
 Test for equality with another vector with epsilon.
 
Angle (const BaseVector3 &rhs) const
 Returns the angle between this vector and another vector in degrees, from 0 to 180.
 
SignedAngle (const BaseVector3 &rhs, const BaseVector3 &axis) const
 
bool IsNaN () const
 Return whether any component is NaN.
 
bool IsInf () const
 Return whether any component is Inf.
 
BaseVector3 Normalized () const
 Return normalized to unit length.
 
BaseVector3 NormalizedOrDefault (const BaseVector3 &defaultValue=BaseVector3::ZERO, T eps=static_cast< T >(M_LARGE_EPSILON)) const
 Return normalized to unit length or zero if length is too small.
 
BaseVector3 ReNormalized (T minLength, T maxLength, const BaseVector3 &defaultValue=BaseVector3::ZERO, T eps=static_cast< T >(M_LARGE_EPSILON)) const
 Return normalized vector with length in given range.
 
constexpr const T * Data () const
 Return data.
 
constexpr T * MutableData ()
 Return mutable data.
 
ea::string ToString () const
 Return as string.
 
unsigned ToHash () const
 Return hash value for HashSet & HashMap.
 
template<class OtherVectorType >
constexpr OtherVectorType Cast (typename OtherVectorType::ScalarType w={}) const
 Cast vector to different type.
 
template<class OtherVectorType >
constexpr OtherVectorType CastXZ (typename OtherVectorType::ScalarType w={}) const
 Cast vector to different type. Y and Z components are shuffled.
 
IntVector2 ToIntVector2 () const
 Return IntVector2 vector (z component is ignored).
 
Vector2 ToVector2 () const
 Return Vector2 vector (z component is ignored).
 
IntVector3 ToIntVector3 () const
 Return IntVector3 vector.
 
Vector4 ToVector4 (float w=0.0f) const
 Return Vector4 vector.
 
BaseVector2< T > ToXZ () const
 Return x and z components as 2D vector (y component is ignored).
 

Static Public Member Functions

static constexpr BaseVector3 FromXZ (const BaseVector2< T > &vector, T y=T{0})
 Construct from 2D vector in X0Z plane.
 

Public Attributes

x_ {}
 X coordinate.
 
y_ {}
 Y coordinate.
 
z_ {}
 Z coordinate.
 

Static Public Attributes

static const BaseVector3< T > ZERO {T{0}, T{0}, T{0}}
 Zero vector.
 
static const BaseVector3< T > LEFT {T{-1}, T{0}, T{0}}
 (-1,0,0) vector.
 
static const BaseVector3< T > RIGHT {T{1}, T{0}, T{0}}
 (1,0,0) vector.
 
static const BaseVector3< T > UP {T{0}, T{1}, T{0}}
 (0,1,0) vector.
 
static const BaseVector3< T > DOWN {T{0}, T{-1}, T{0}}
 (0,-1,0) vector.
 
static const BaseVector3< T > FORWARD {T{0}, T{0}, T{1}}
 (0,0,1) vector.
 
static const BaseVector3< T > BACK {T{0}, T{0}, T{-1}}
 (0,0,-1) vector.
 
static const BaseVector3< T > ONE {T{1}, T{1}, T{1}}
 (1,1,1) vector.
 
- Static Public Attributes inherited from Urho3D::Detail::VectorTraits< T, 3 >
static constexpr int NumComponents
 Number of compo.
 

Additional Inherited Members

- Public Types inherited from Urho3D::Detail::VectorTraits< T, 3 >
using ScalarType = T
 Underlying scalar type.
 

Detailed Description

template<class T>
class Urho3D::BaseVector3< T >

Three-dimensional vector with real-number values.

Member Function Documentation

◆ Length()

template<class T >
T Urho3D::BaseVector3< T >::Length ( ) const
inline

Return length.

◆ LengthSquared()

template<class T >
constexpr T Urho3D::BaseVector3< T >::LengthSquared ( ) const
inlineconstexpr

Return squared length.

◆ SignedAngle()

template<class T >
T Urho3D::BaseVector3< T >::SignedAngle ( const BaseVector3< T > &  rhs,
const BaseVector3< T > &  axis 
) const
inline

Returns the signed angle between this vector and another vector in degrees, from -180 to 180. Axis is used to determine the sign of the angle. If axis is orthogonal to both vectors, it is guaranteed that quaternion rotation with this axis and angle will result in transition from first vector to the second one.


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