Rebel Fork Framework
Urho3D::Vector3 Class Reference

Three-dimensional vector. More...

#include <Urho3D/Math/Vector3.h>

Public Member Functions

 Vector3 () noexcept
 Construct a zero vector.
 
 Vector3 (const Vector3 &vector) noexcept=default
 Copy-construct from another vector.
 
 Vector3 (float x, float y, float z) noexcept
 Construct from coordinates.
 
 Vector3 (float x, float y) noexcept
 Construct from two-dimensional coordinates (for Urho2D).
 
 Vector3 (const float data[]) noexcept
 Construct from a float array.
 
Vector3operator= (const Vector3 &rhs) noexcept=default
 Assign from another vector.
 
bool operator== (const Vector3 &rhs) const
 Test for equality with another vector without epsilon.
 
bool operator!= (const Vector3 &rhs) const
 Test for inequality with another vector without epsilon.
 
Vector3 operator+ (const Vector3 &rhs) const
 Add a vector.
 
Vector3 operator- () const
 Return negation.
 
Vector3 operator- (const Vector3 &rhs) const
 Subtract a vector.
 
Vector3 operator* (float rhs) const
 Multiply with a scalar.
 
Vector3 operator* (const Vector3 &rhs) const
 Multiply with a vector.
 
Vector3 operator/ (float rhs) const
 Divide by a scalar.
 
Vector3 operator/ (const Vector3 &rhs) const
 Divide by a vector.
 
Vector3operator+= (const Vector3 &rhs)
 Add-assign a vector.
 
Vector3operator-= (const Vector3 &rhs)
 Subtract-assign a vector.
 
Vector3operator*= (float rhs)
 Multiply-assign a scalar.
 
Vector3operator*= (const Vector3 &rhs)
 Multiply-assign a vector.
 
Vector3operator/= (float rhs)
 Divide-assign a scalar.
 
Vector3operator/= (const Vector3 &rhs)
 Divide-assign a vector.
 
void Normalize ()
 Normalize to unit length.
 
float Length () const
 
float LengthSquared () const
 
float DotProduct (const Vector3 &rhs) const
 Calculate dot product.
 
float AbsDotProduct (const Vector3 &rhs) const
 Calculate absolute dot product.
 
float ProjectOntoAxis (const Vector3 &axis) const
 Project direction vector onto axis.
 
Vector3 ProjectOntoPlane (const Vector3 &origin, const Vector3 &normal) const
 Project position vector onto plane with given origin and normal.
 
Vector3 ProjectOntoLine (const Vector3 &from, const Vector3 &to, bool clamped=false) const
 Project position vector onto line segment.
 
float DistanceToPoint (const Vector3 &point) const
 Calculate distance to another position vector.
 
float DistanceToPlane (const Vector3 &origin, const Vector3 &normal) const
 Calculate distance to the plane with given origin and normal.
 
Vector3 Orthogonalize (const Vector3 &axis) const
 Make vector orthogonal to the axis.
 
Vector3 CrossProduct (const Vector3 &rhs) const
 Calculate cross product.
 
Vector3 Abs () const
 Return absolute vector.
 
Vector3 Lerp (const Vector3 &rhs, float t) const
 Linear interpolation with another vector.
 
bool Equals (const Vector3 &rhs, float eps=M_EPSILON) const
 Test for equality with another vector with epsilon.
 
float Angle (const Vector3 &rhs) const
 Returns the angle between this vector and another vector in degrees, from 0 to 180.
 
float SignedAngle (const Vector3 &rhs, const Vector3 &axis) const
 
bool IsNaN () const
 Return whether any component is NaN.
 
bool IsInf () const
 Return whether any component is Inf.
 
Vector3 Normalized () const
 Return normalized to unit length.
 
Vector3 NormalizedOrDefault (const Vector3 &defaultValue=Vector3::ZERO, float eps=M_LARGE_EPSILON) const
 Return normalized to unit length or zero if length is too small.
 
Vector3 ReNormalized (float minLength, float maxLength, const Vector3 &defaultValue=Vector3::ZERO, float eps=M_LARGE_EPSILON) const
 Return normalized vector with length in given range.
 
const float * Data () const
 Return float data.
 
ea::string ToString () const
 Return as string.
 
unsigned ToHash () const
 Return hash value for HashSet & HashMap.
 
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.
 
Vector2 ToXZ () const
 Return x and z components as 2D vector (y component is ignored).
 

Static Public Member Functions

static Vector3 FromXZ (const Vector2 &vector, float y=0.0f)
 Construct from 2D vector in X0Z plane.
 

Public Attributes

float x_
 X coordinate.
 
float y_
 Y coordinate.
 
float z_
 Z coordinate.
 

Static Public Attributes

static const Vector3 ZERO
 Zero vector.
 
static const Vector3 LEFT
 (-1,0,0) vector.
 
static const Vector3 RIGHT
 (1,0,0) vector.
 
static const Vector3 UP
 (0,1,0) vector.
 
static const Vector3 DOWN
 (0,-1,0) vector.
 
static const Vector3 FORWARD
 (0,0,1) vector.
 
static const Vector3 BACK
 (0,0,-1) vector.
 
static const Vector3 ONE
 (1,1,1) vector.
 

Detailed Description

Three-dimensional vector.

Member Function Documentation

◆ Length()

float Urho3D::Vector3::Length ( ) const
inline

Return length.

◆ LengthSquared()

float Urho3D::Vector3::LengthSquared ( ) const
inline

Return squared length.

◆ SignedAngle()

float Urho3D::Vector3::SignedAngle ( const Vector3 rhs,
const Vector3 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: