Urho3D::Vector3 Class Reference

Three-dimensional vector. More...

`#include <Urho3D/Math/Vector3.h>`

Collaboration diagram for Urho3D::Vector3:
[legend]

## Public Member Functions

Vector3 () noexcept
Construct a zero vector.

Vector3 (const Vector3 &vector) noexcept=default
Copy-construct from another vector.

Vector3 (const Vector2 &vector, float z) noexcept
Construct from a two-dimensional vector and the Z coordinate.

Vector3 (const Vector2 &vector) noexcept
Construct from a two-dimensional vector (for Urho2D).

Vector3 (const IntVector3 &vector) noexcept
Construct from an IntVector3.

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

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)

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

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.

String ToString () const
Return as string.

unsigned ToHash () const
Return hash value for HashSet & HashMap.

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.

## ◆ Length()

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

Return length.

Here is the caller graph for this function:

## ◆ LengthSquared()

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

Return squared length.

Here is the caller graph for this function:

The documentation for this class was generated from the following files:
• Source/Urho3D/Math/Vector3.h
• Source/Urho3D/Math/Vector3.cpp