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

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

#include <Urho3D/Math/Vector2.h>

Inheritance diagram for Urho3D::BaseVector2< T >:
Urho3D::Detail::VectorTraits< T, 2 >

Public Member Functions

constexpr BaseVector2 () noexcept=default
 Construct a zero vector.
 
constexpr BaseVector2 (T x, T y) noexcept
 Construct from coordinates.
 
constexpr BaseVector2 (const T data[]) noexcept
 Construct from a scalar array.
 
constexpr auto Tie () const
 Convert to tuple.
 
constexpr bool operator== (const BaseVector2 &rhs) const
 Test for equality with another vector without epsilon.
 
constexpr bool operator!= (const BaseVector2 &rhs) const
 Test for inequality with another vector without epsilon.
 
constexpr BaseVector2 operator+ (const BaseVector2 &rhs) const
 Add a vector.
 
constexpr BaseVector2 operator- () const
 Return negation.
 
constexpr BaseVector2 operator- (const BaseVector2 &rhs) const
 Subtract a vector.
 
constexpr BaseVector2 operator* (T rhs) const
 Multiply with a scalar.
 
constexpr BaseVector2 operator* (const BaseVector2 &rhs) const
 Multiply with a vector.
 
constexpr BaseVector2 operator/ (T rhs) const
 Divide by a scalar.
 
constexpr BaseVector2 operator/ (const BaseVector2 &rhs) const
 Divide by a vector.
 
constexpr BaseVector2operator+= (const BaseVector2 &rhs)
 Add-assign a vector.
 
constexpr BaseVector2operator-= (const BaseVector2 &rhs)
 Subtract-assign a vector.
 
constexpr BaseVector2operator*= (T rhs)
 Multiply-assign a scalar.
 
constexpr BaseVector2operator*= (const BaseVector2 &rhs)
 Multiply-assign a vector.
 
constexpr BaseVector2operator/= (T rhs)
 Divide-assign a scalar.
 
constexpr BaseVector2operator/= (const BaseVector2 &rhs)
 Divide-assign a vector.
 
void Normalize ()
 Normalize to unit length.
 
Length () const
 
constexpr T LengthSquared () const
 
constexpr T DotProduct (const BaseVector2 &rhs) const
 Calculate dot product.
 
AbsDotProduct (const BaseVector2 &rhs) const
 Calculate absolute dot product.
 
constexpr T CrossProduct (const BaseVector2 &rhs) const
 Calculate "cross product" aka z component of cross product of (x1, y1, 0) and (x2, y2, 0).
 
ProjectOntoAxis (const BaseVector2 &axis) const
 Project vector onto axis.
 
ProjectOntoLineScalar (const BaseVector2 &from, const BaseVector2 &to, bool clamped=false) const
 Project position vector onto line segment. Returns interpolation factor between line points.
 
BaseVector2 ProjectOntoLine (const BaseVector2 &from, const BaseVector2 &to, bool clamped=false) const
 Project position vector onto line segment. Returns new position.
 
DistanceToPoint (const BaseVector2 &point) const
 Calculate distance to another position vector.
 
constexpr T ScalarCrossProduct (const BaseVector2 &rhs) const
 Return scalar cross product of 2D vectors.
 
Angle (const BaseVector2 &rhs) const
 Returns the angle between this vector and another vector in degrees.
 
SignedAngle (const BaseVector2 &rhs) const
 Returns signed angle between this vector and another vector in degrees. Clockwise direction is positive.
 
BaseVector2 Abs () const
 Return absolute vector.
 
BaseVector2 Lerp (const BaseVector2 &rhs, T t) const
 Linear interpolation with another vector.
 
bool Equals (const BaseVector2 &rhs, T eps=static_cast< T >(M_EPSILON)) const
 Test for equality with another vector with epsilon.
 
bool IsNaN () const
 Return whether any component is NaN.
 
bool IsInf () const
 Return whether any component is Inf.
 
BaseVector2 Normalized () const
 Return normalized to unit length.
 
BaseVector2 NormalizedOrDefault (const BaseVector2 &defaultValue=BaseVector2::ZERO, T eps=static_cast< T >(M_LARGE_EPSILON)) const
 Return normalized to unit length or zero if length is too small.
 
BaseVector2 ReNormalized (T minLength, T maxLength, const BaseVector2 &defaultValue=BaseVector2::ZERO, T eps=static_cast< T >(M_LARGE_EPSILON)) const
 Return normalized vector with length in given range.
 
constexpr BaseVector2 GetOrthogonalClockwise () const
 Return orthogonal vector (clockwise).
 
constexpr BaseVector2 GetOrthogonalCounterClockwise () const
 Return orthogonal vector (counter-clockwise).
 
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 z={}, typename OtherVectorType::ScalarType w={}) const
 Cast vector to different type.
 
template<class OtherVectorType >
constexpr OtherVectorType CastXZ (typename OtherVectorType::ScalarType z={}, typename OtherVectorType::ScalarType w={}) const
 Cast vector to different type. Y and Z components are shuffled.
 
IntVector2 ToIntVector2 () const
 Return IntVector2 vector.
 
IntVector3 ToIntVector3 (int z=0) const
 Return IntVector3 vector.
 
Vector3 ToVector3 (float z=0.0f) const
 Return Vector3 vector.
 
Vector4 ToVector4 (float z=0.0f, float w=0.0f) const
 Return Vector4 vector.
 

Public Attributes

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

Static Public Attributes

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

Additional Inherited Members

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

Detailed Description

template<class T>
class Urho3D::BaseVector2< T >

Two-dimensional vector with real-number values.

Member Function Documentation

◆ Length()

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

Return length.

◆ LengthSquared()

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

Return squared length.


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