U3D
Open-source, cross-platform 2D and 3D game engine built in C++
Loading...
Searching...
No Matches
Urho3D::Vector2 Class Reference

Two-dimensional vector. More...

#include </var/dev/u3d/stable/Source/Urho3D/Math/Vector2.h>

Collaboration diagram for Urho3D::Vector2:
[legend]

Public Member Functions

 Vector2 () noexcept
 Construct a zero vector.
 
 Vector2 (const Vector2 &vector) noexcept=default
 Copy-construct from another vector.
 
 Vector2 (const IntVector2 &vector) noexcept
 Construct from an IntVector2.
 
 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 ProjectOntoAxis (const Vector2 &axis) const
 Project vector onto axis.
 
float Angle (const Vector2 &rhs) const
 Returns the angle between this vector and another vector in degrees.
 
Vector2 Abs () const
 Return absolute vector.
 
Vector2 Lerp (const Vector2 &rhs, float t) const
 Linear interpolation with another vector.
 
bool Equals (const Vector2 &rhs) 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.
 
const float * Data () const
 Return float data.
 
String ToString () const
 Return as string.
 

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.

Here is the caller graph for this function:

◆ LengthSquared()

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

Return squared length.


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