1#ifndef RAYLIB_CPP_INCLUDE_VECTOR2_HPP_
2#define RAYLIB_CPP_INCLUDE_VECTOR2_HPP_
4#ifndef RAYLIB_CPP_NO_MATH
9#include "./raymath.hpp"
10#include "./raylib-cpp-utils.hpp"
26 GETTERSETTER(
float, X, x)
27 GETTERSETTER(
float, Y, y)
40 return !(*
this == other);
43#ifndef RAYLIB_CPP_NO_MATH
45 return Vector2Add(*
this, vector2);
49 return Vector2Add(*
this, vector2);
53 return Vector2Subtract(*
this, vector2);
57 return Vector2Subtract(*
this, vector2);
61 return Vector2Negate(*
this);
65 return Vector2Negate(*
this);
69 return Vector2Multiply(*
this, vector2);
73 return Vector2Multiply(*
this, vector2);
77 return Vector2Scale(*
this, scale);
81 return Vector2Scale(*
this, scale);
85 return Vector2Divide(*
this, vector2);
89 return Vector2Divide(*
this, vector2);
93 return ::Vector2{x / div, y / div};
101 set(Vector2Add(*
this, vector2));
107 set(Vector2Subtract(*
this, vector2));
114 set(Vector2Multiply(*
this, vector2));
120 set(Vector2Scale(*
this, scale));
126 set(Vector2Divide(*
this, vector2));
142 return Vector2Length(*
this);
149 return Vector2LengthSqr(*
this);
156 return Vector2Normalize(*
this);
163 return Vector2DotProduct(*
this, vector2);
169 float Angle(const ::Vector2& vector2)
const {
170 return Vector2Angle(*
this, vector2);
177 return Vector2Distance(*
this, vector2);
184 return Vector2Lerp(*
this, vector2, amount);
191 return Vector2Reflect(*
this, normal);
198 return Vector2Rotate(*
this, degrees);
205 return Vector2MoveTowards(*
this, target, maxDistance);
212 return Vector2Zero();
224 ::DrawPixelV(*
this, color);
229 ::DrawLineV(*
this, endPos, color);
234 ::DrawLineEx(*
this, endPos, thick, color);
259 ::DrawCircleV(*
this, radius, color);
264 ::DrawRectangleV(*
this, size, color);
269 ::DrawPoly(*
this, sides, radius, rotation, color);
277 return ::CheckCollisionCircles(*
this, radius1, center2, radius2);
284 return ::CheckCollisionCircleRec(*
this, radius, rec);
291 return ::CheckCollisionPointRec(*
this, rec);
298 return ::CheckCollisionPointCircle(*
this, center, radius);
305 return ::CheckCollisionPointTriangle(*
this, p1, p2, p3);
315 return ::CheckCollisionLines(*
this, endPos1, startPos2, endPos2, collisionPoint);
319 inline void set(const ::Vector2& vec) {
Vector2 & DrawLineBezierQuad(::Vector2 endPos, ::Vector2 controlPos, float thick, ::Color color)
Draw line using quadratic bezier curves with a control point.
Vector2 & operator-=(const ::Vector2 &vector2)
bool CheckCollision(::Vector2 p1, ::Vector2 p2, ::Vector2 p3) const
Check if point is inside a triangle.
Vector2 & DrawCircle(float radius, ::Color color)
Draw a color-filled circle (Vector version)
Vector2 MoveTowards(const ::Vector2 &target, float maxDistance) const
Move Vector towards target.
Vector2 Subtract(const ::Vector2 &vector2) const
Vector2 operator*(const float scale) const
bool CheckCollision(::Rectangle rec) const
Check if point is inside rectangle.
Vector2 Lerp(const ::Vector2 &vector2, float amount) const
Calculate linear interpolation between two vectors.
Vector2 & DrawLine(::Vector2 endPos, float thick, ::Color color)
Vector2 & operator*=(const float scale)
Vector2 & operator/=(const ::Vector2 &vector2)
Vector2 & DrawPixel(::Color color)
float Length() const
Calculate vector length.
float DotProduct(const ::Vector2 &vector2) const
Calculate two vectors dot product.
Vector2 Rotate(float degrees) const
Rotate Vector by float in Degrees.
float LengthSqr() const
Calculate vector square length.
float Distance(const ::Vector2 &vector2) const
Calculate distance between two vectors.
Vector2 & operator+=(const ::Vector2 &vector2)
bool CheckCollision(::Vector2 center, float radius) const
Check if point is inside circle.
Vector2 Divide(const ::Vector2 &vector2) const
bool CheckCollisionCircle(float radius, ::Rectangle rec) const
Check collision between circle and rectangle.
static Vector2 Zero()
Vector with components value 0.0f.
bool CheckCollisionCircle(float radius1, ::Vector2 center2, float radius2) const
Check collision between two circles.
Vector2 Reflect(const ::Vector2 &normal) const
Calculate reflected vector to normal.
Vector2 Multiply(const ::Vector2 &vector2) const
Vector2 operator+(const ::Vector2 &vector2) const
Vector2 operator/(const ::Vector2 &vector2) const
bool operator==(const ::Vector2 &other)
Vector2 Scale(const float scale) const
Vector2 Add(const ::Vector2 &vector2) const
Vector2 operator*(const ::Vector2 &vector2) const
Vector2 operator/(const float div) const
Vector2 & DrawPoly(int sides, float radius, float rotation, ::Color color)
Vector2(float x, float y)
Vector2 & operator*=(const ::Vector2 &vector2)
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 referenc...
static Vector2 One()
Vector with components value 1.0f.
Vector2 & DrawLineBezier(::Vector2 endPos, float thick, ::Color color)
Vector2 & DrawLine(::Vector2 endPos, ::Color color)
Vector2 & operator/=(const float div)
bool operator!=(const ::Vector2 &other)
Vector2 Normalize() const
Normalize provided vector.
Vector2 operator-() const
Vector2(const ::Vector2 &vec)
Vector2 & DrawRectangle(::Vector2 size, ::Color color)
Vector2 operator-(const ::Vector2 &vector2) const
float Angle(const ::Vector2 &vector2) const
Calculate angle from two vectors in X-axis.
Vector2 Divide(const float div) const
All raylib-cpp classes and functions appear in the raylib namespace.