raylib-cpp
C++ object-oriented wrapper library for raylib.
Public Member Functions | Static Public Member Functions | List of all members
raylib::Vector2 Class Reference

Vector2 type. More...

Public Member Functions

 Vector2 (const ::Vector2 &vec)
 
 Vector2 (float x)
 
 Vector2 (float x, float y)
 
Vector2 Add (const ::Vector2 &vector2) const
 
float Angle (const ::Vector2 &vector2) const
 Calculate angle from two vectors in X-axis.
 
bool CheckCollision (::Rectangle rec) const
 Check if point is inside rectangle.
 
bool CheckCollision (::Vector2 center, float radius) const
 Check if point is inside circle.
 
bool CheckCollision (::Vector2 p1, ::Vector2 p2, ::Vector2 p3) const
 Check if point is inside a triangle.
 
bool CheckCollisionCircle (float radius, ::Rectangle rec) const
 Check collision between circle and rectangle.
 
bool CheckCollisionCircle (float radius1, ::Vector2 center2, float radius2) const
 Check collision between two circles.
 
bool CheckCollisionLines (::Vector2 endPos1, ::Vector2 startPos2, ::Vector2 endPos2, ::Vector2 *collisionPoint) const
 Check the collision between two lines defined by two points each, returns collision point by reference.
 
float Distance (const ::Vector2 &vector2) const
 Calculate distance between two vectors.
 
Vector2 Divide (const ::Vector2 &vector2) const
 
Vector2 Divide (const float div) const
 
float DotProduct (const ::Vector2 &vector2) const
 Calculate two vectors dot product.
 
Vector2DrawCircle (float radius, ::Color color)
 Draw a color-filled circle (Vector version)
 
Vector2DrawLine (::Vector2 endPos, ::Color color)
 
Vector2DrawLine (::Vector2 endPos, float thick, ::Color color)
 
Vector2DrawLineBezier (::Vector2 endPos, float thick, ::Color color)
 
Vector2DrawLineBezierQuad (::Vector2 endPos, ::Vector2 controlPos, float thick, ::Color color)
 Draw line using quadratic bezier curves with a control point.
 
Vector2DrawPixel (::Color color)
 
Vector2DrawPoly (int sides, float radius, float rotation, ::Color color)
 
Vector2DrawRectangle (::Vector2 size, ::Color color)
 
float GetX () const
 Retrieves the x value for the object. More...
 
float GetY () const
 Retrieves the y value for the object. More...
 
float Length () const
 Calculate vector length.
 
float LengthSqr () const
 Calculate vector square length.
 
Vector2 Lerp (const ::Vector2 &vector2, float amount) const
 Calculate linear interpolation between two vectors.
 
Vector2 MoveTowards (const ::Vector2 &target, float maxDistance) const
 Move Vector towards target.
 
Vector2 Multiply (const ::Vector2 &vector2) const
 
Vector2 Negate () const
 
Vector2 Normalize () const
 Normalize provided vector.
 
bool operator!= (const ::Vector2 &other)
 
Vector2 operator* (const ::Vector2 &vector2) const
 
Vector2 operator* (const float scale) const
 
Vector2operator*= (const ::Vector2 &vector2)
 
Vector2operator*= (const float scale)
 
Vector2 operator+ (const ::Vector2 &vector2) const
 
Vector2operator+= (const ::Vector2 &vector2)
 
Vector2 operator- () const
 
Vector2 operator- (const ::Vector2 &vector2) const
 
Vector2operator-= (const ::Vector2 &vector2)
 
Vector2 operator/ (const ::Vector2 &vector2) const
 
Vector2 operator/ (const float div) const
 
Vector2operator/= (const ::Vector2 &vector2)
 
Vector2operator/= (const float div)
 
Vector2operator= (const ::Vector2 &vector2)
 
bool operator== (const ::Vector2 &other)
 
Vector2 Reflect (const ::Vector2 &normal) const
 Calculate reflected vector to normal.
 
Vector2 Rotate (float degrees) const
 Rotate Vector by float in Degrees.
 
Vector2 Scale (const float scale) const
 
void SetX (float value)
 Sets the x value for the object. More...
 
void SetY (float value)
 Sets the y value for the object. More...
 
Vector2 Subtract (const ::Vector2 &vector2) const
 

Static Public Member Functions

static Vector2 One ()
 Vector with components value 1.0f.
 
static Vector2 Zero ()
 Vector with components value 0.0f.
 

Detailed Description

Vector2 type.

Definition at line 16 of file Vector2.hpp.

Member Function Documentation

◆ GetX()

float raylib::Vector2::GetX ( ) const
inline

Retrieves the x value for the object.

Returns
The x value of the object.

Definition at line 26 of file Vector2.hpp.

◆ GetY()

float raylib::Vector2::GetY ( ) const
inline

Retrieves the y value for the object.

Returns
The y value of the object.

Definition at line 27 of file Vector2.hpp.

◆ SetX()

void raylib::Vector2::SetX ( float  value)
inline

Sets the x value for the object.

Parameters
valueThe value of which to set x to.

Definition at line 26 of file Vector2.hpp.

◆ SetY()

void raylib::Vector2::SetY ( float  value)
inline

Sets the y value for the object.

Parameters
valueThe value of which to set y to.

Definition at line 27 of file Vector2.hpp.