Rebel Fork Framework
Urho3D::Vector2 Class Reference

Two-dimensional vector. More...

#include <Urho3D/Math/Vector2.h>

Public Member Functions

 Vector2 () noexcept
 Construct a zero vector.
 
 Vector2 (const Vector2 &vector) noexcept=default
 Copy-construct from another vector.
 
 Vector2 (float x, float y) noexcept
 Construct from coordinates.
 
 Vector2 (const float data[]) noexcept
 Construct from a float array.
 
Vector2operator= (const Vector2 &rhs) noexcept=default
 Assign from another vector.
 
bool operator== (const Vector2 &rhs) const
 Test for equality with another vector without epsilon.
 
bool operator!= (const Vector2 &rhs) const
 Test for inequality with another vector without epsilon.
 
Vector2 operator+ (const Vector2 &rhs) const
 Add a vector.
 
Vector2 operator- () const
 Return negation.
 
Vector2 operator- (const Vector2 &rhs) const
 Subtract a vector.
 
Vector2 operator* (float rhs) const
 Multiply with a scalar.
 
Vector2 operator* (const Vector2 &rhs) const
 Multiply with a vector.
 
Vector2 operator/ (float rhs) const
 Divide by a scalar.
 
Vector2 operator/ (const Vector2 &rhs) const
 Divide by a vector.
 
Vector2operator+= (const Vector2 &rhs)
 Add-assign a vector.
 
Vector2operator-= (const Vector2 &rhs)
 Subtract-assign a vector.
 
Vector2operator*= (float rhs)
 Multiply-assign a scalar.
 
Vector2operator*= (const Vector2 &rhs)
 Multiply-assign a vector.
 
Vector2operator/= (float rhs)
 Divide-assign a scalar.
 
Vector2operator/= (const Vector2 &rhs)
 Divide-assign a vector.
 
void Normalize ()
 Normalize to unit length.
 
float Length () const
 
float LengthSquared () const
 
float DotProduct (const Vector2 &rhs) const
 Calculate dot product.
 
float AbsDotProduct (const Vector2 &rhs) const
 Calculate absolute dot product.
 
float CrossProduct (const Vector2 &rhs) const
 Calculate "cross product" aka z component of cross product of (x1, y1, 0) and (x2, y2, 0).
 
float ProjectOntoAxis (const Vector2 &axis) const
 Project vector onto axis.
 
float ScalarCrossProduct (const Vector2 &rhs) const
 Return scalar cross product of 2D vectors.
 
float Angle (const Vector2 &rhs) const
 Returns the angle between this vector and another vector in degrees.
 
float SignedAngle (const Vector2 &rhs) const
 Returns signed angle between this vector and another vector in degrees. Clockwise direction is positive.
 
Vector2 Abs () const
 Return absolute vector.
 
Vector2 Lerp (const Vector2 &rhs, float t) const
 Linear interpolation with another vector.
 
bool Equals (const Vector2 &rhs, float eps=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.
 
Vector2 Normalized () const
 Return normalized to unit length.
 
Vector2 NormalizedOrDefault (const Vector2 &defaultValue=Vector2::ZERO, float eps=M_LARGE_EPSILON) const
 Return normalized to unit length or zero if length is too small.
 
Vector2 ReNormalized (float minLength, float maxLength, const Vector2 &defaultValue=Vector2::ZERO, float eps=M_LARGE_EPSILON) const
 Return normalized vector with length in given range.
 
Vector2 GetOrthogonalClockwise () const
 Return orthogonal vector (clockwise).
 
Vector2 GetOrthogonalCounterClockwise () const
 Return orthogonal vector (counter-clockwise).
 
const float * Data () const
 Return float data.
 
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.
 
ea::string ToString () const
 Return as string.
 
unsigned ToHash () const
 Return hash value for HashSet & HashMap.
 

Public Attributes

float x_
 X coordinate.
 
float y_
 Y coordinate.
 

Static Public Attributes

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

Detailed Description

Two-dimensional vector.

Member Function Documentation

◆ Length()

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

Return length.

◆ LengthSquared()

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

Return squared length.


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