1#ifndef RAYLIB_CPP_INCLUDE_VECTOR3_HPP_
2#define RAYLIB_CPP_INCLUDE_VECTOR3_HPP_
4#ifndef RAYLIB_CPP_NO_MATH
10#include "./raylib-cpp-utils.hpp"
11#include "./raylib.hpp"
12#include "./raymath.hpp"
13#include "./raylib-cpp-utils.hpp"
14#include "./RadiansDegrees.hpp"
22 Vector3(const ::Vector3& vec) : ::Vector3{vec.x, vec.y, vec.z} {}
24 Vector3(
float x,
float y,
float z) : ::Vector3{x, y, z} {}
25 Vector3(
float x,
float y) : ::Vector3{x, y, 0} {}
26 Vector3(
float x) : ::Vector3{x, 0, 0} {}
27 Vector3() : ::Vector3{0, 0, 0} {}
29 Vector3(::Color color) { set(ColorToHSV(color)); }
31 GETTERSETTER(
float, X, x)
32 GETTERSETTER(
float, Y, y)
33 GETTERSETTER(
float, Z, z)
40 bool operator==(const ::Vector3& other)
const {
return x == other.x && y == other.y && z == other.z; }
42 bool operator!=(const ::Vector3& other)
const {
return !(*
this == other); }
44 [[nodiscard]] std::string ToString()
const {
return TextFormat(
"Vector3(%f, %f, %f)", x, y, z); }
46 operator std::string()
const {
return ToString(); }
48#ifndef RAYLIB_CPP_NO_MATH
52 [[nodiscard]]
Vector3 Add(const ::Vector3& vector3)
const {
return Vector3Add(*
this, vector3); }
57 Vector3 operator+(const ::Vector3& vector3)
const {
return Vector3Add(*
this, vector3); }
59 Vector3& operator+=(const ::Vector3& vector3) {
60 set(Vector3Add(*
this, vector3));
69 return Vector3AddValue(*
this, value);
76 return Vector3AddValue(*
this, value);
79 Vector3& operator+=(
float value) {
80 set(Vector3AddValue(*
this, value));
88 [[nodiscard]]
Vector3 Subtract(const ::Vector3& vector3)
const {
return Vector3Subtract(*
this, vector3); }
93 Vector3 operator-(const ::Vector3& vector3)
const {
return Vector3Subtract(*
this, vector3); }
95 Vector3& operator-=(const ::Vector3& vector3) {
96 set(Vector3Subtract(*
this, vector3));
105 return Vector3SubtractValue(*
this, value);
112 return Vector3SubtractValue(*
this, value);
115 Vector3& operator-=(
float value) {
116 set(Vector3SubtractValue(*
this, value));
134 [[nodiscard]]
Vector3 Multiply(const ::Vector3& vector3)
const {
return Vector3Multiply(*
this, vector3); }
139 Vector3 operator*(const ::Vector3& vector3)
const {
return Vector3Multiply(*
this, vector3); }
145 set(Vector3Multiply(*
this, vector3));
153 [[nodiscard]]
Vector3 Scale(
const float scaler)
const {
return Vector3Scale(*
this, scaler); }
164 set(Vector3Scale(*
this, scaler));
172 [[nodiscard]]
Vector3 Divide(const ::Vector3& vector3)
const {
return Vector3Divide(*
this, vector3); }
177 Vector3 operator/(const ::Vector3& vector3)
const {
return Vector3Divide(*
this, vector3); }
193 [[nodiscard]]
Vector3 Divide(
const float div)
const { return ::Vector3{x / div, y / div, z / div}; }
214 [[nodiscard]]
float Length()
const {
return Vector3Length(*
this); }
219 [[nodiscard]]
float LengthSqr()
const {
return Vector3LengthSqr(*
this); }
221 [[nodiscard]]
Vector3 Normalize()
const {
return Vector3Normalize(*
this); }
223 [[nodiscard]]
float DotProduct(const ::Vector3& vector3)
const {
return Vector3DotProduct(*
this, vector3); }
225 [[nodiscard]]
float Distance(const ::Vector3& vector3)
const {
return Vector3Distance(*
this, vector3); }
227 [[nodiscard]] Vector3 Lerp(const ::Vector3& vector3,
const float amount)
const {
return Vector3Lerp(*
this, vector3, amount); }
229 [[nodiscard]] Vector3 CrossProduct(const ::Vector3& vector3)
const {
return Vector3CrossProduct(*
this, vector3); }
231 [[nodiscard]] Vector3 Perpendicular()
const {
return Vector3Perpendicular(*
this); }
233 [[nodiscard]] Vector3 Project(const ::Vector3& vector3)
const {
return Vector3Project(*
this, vector3); }
235 [[nodiscard]] Vector3 Reject(const ::Vector3& vector3)
const {
return Vector3Reject(*
this, vector3); }
237 void OrthoNormalize(::Vector3* vector3) { Vector3OrthoNormalize(
this, vector3); }
239 [[nodiscard]] Vector3 Transform(const ::Matrix& matrix)
const {
return Vector3Transform(*
this, matrix); }
241 [[nodiscard]] Vector3 RotateByQuaternion(const ::Quaternion& quaternion)
const {
242 return Vector3RotateByQuaternion(*
this, quaternion);
245 [[nodiscard]] Vector3 Reflect(const ::Vector3& normal)
const {
return Vector3Reflect(*
this, normal); }
247 [[nodiscard]] Vector3 Min(const ::Vector3& vector3)
const {
return Vector3Min(*
this, vector3); }
249 [[nodiscard]] Vector3 Max(const ::Vector3& vector3)
const {
return Vector3Max(*
this, vector3); }
251 [[nodiscard]] Vector3 Barycenter(const ::Vector3& a, const ::Vector3& b, const ::Vector3& c)
const {
252 return Vector3Barycenter(*
this, a, b, c);
255 static Vector3 Zero() {
return Vector3Zero(); }
257 static Vector3 One() {
261 static inline Vector3 Left() {
265 static inline Vector3 Right() {
269 static inline Vector3 Up() {
273 static inline Vector3 Down() {
277 static inline Vector3 Forward() {
281 static inline Vector3 Back() {
286 void DrawLine3D(const ::Vector3& endPos, ::Color color)
const { ::DrawLine3D(*
this, endPos, color); }
288 void DrawPoint3D(::Color color)
const { ::DrawPoint3D(*
this, color); }
292 const ::Vector3& rotationAxis,
293 Radian rotationAngle,
295 ::DrawCircle3D(*
this, radius, rotationAxis, rotationAngle, color);
298 void DrawCube(
float width,
float height,
float length, ::Color color)
const {
299 ::DrawCube(*
this, width, height, length, color);
302 void DrawCube(const ::Vector3& size, ::Color color)
const { ::DrawCubeV(*
this, size, color); }
304 void DrawCubeWires(
float width,
float height,
float length, ::Color color)
const {
305 ::DrawCubeWires(*
this, width, height, length, color);
308 void DrawCubeWires(const ::Vector3& size, ::Color color)
const { ::DrawCubeWiresV(*
this, size, color); }
310 void DrawSphere(
float radius, ::Color color)
const { ::DrawSphere(*
this, radius, color); }
312 void DrawSphere(
float radius,
int rings,
int slices, ::Color color)
const {
313 ::DrawSphereEx(*
this, radius, rings, slices, color);
316 void DrawSphereWires(
float radius,
int rings,
int slices, ::Color color)
const {
317 ::DrawSphereWires(*
this, radius, rings, slices, color);
320 void DrawCylinder(
float radiusTop,
float radiusBottom,
float height,
int slices, ::Color color)
const {
321 ::DrawCylinder(*
this, radiusTop, radiusBottom, height, slices, color);
324 void DrawCylinderWires(
float radiusTop,
float radiusBottom,
float height,
int slices, ::Color color)
const {
325 ::DrawCylinderWires(*
this, radiusTop, radiusBottom, height, slices, color);
328 void DrawPlane(const ::Vector2& size, ::Color color)
const { ::DrawPlane(*
this, size, color); }
333 [[nodiscard]]
bool CheckCollision(
float radius1, const ::Vector3& center2,
float radius2)
const {
334 return CheckCollisionSpheres(*
this, radius1, center2, radius2);
337 void set(const ::Vector3& vec) {
Vector3 operator-(float value) const
Subtract vector by float value.
Vector3 operator/(const ::Vector3 &vector3) const
Divide vector by vector.
Vector3 Negate() const
Negate provided vector (invert direction)
Vector3 operator-() const
Negate provided vector (invert direction)
Vector3 & operator/=(const ::Vector3 &vector3)
Divide vector by vector.
Vector3 operator*(const ::Vector3 &vector3) const
Multiply vector by vector.
Vector3 & operator*=(const float scaler)
Multiply vector by scalar.
Vector3 & operator*=(const ::Vector3 &vector3)
Multiply vector by vector.
Vector3 operator/(const float div) const
Divide a vector by a value.
float LengthSqr() const
Calculate vector square length.
Vector3 operator+(const ::Vector3 &vector3) const
Add two vectors.
Vector3 Add(float value) const
Add vector and float value.
Vector3 Add(const ::Vector3 &vector3) const
Add two vectors.
Vector3 Scale(const float scaler) const
Multiply vector by scalar.
float Length() const
Calculate vector length.
Vector3 Divide(const ::Vector3 &vector3) const
Divide vector by vector.
Vector3 Divide(const float div) const
Divide a vector by a value.
Vector3 Subtract(const ::Vector3 &vector3) const
Subtract two vectors.
Vector3 operator+(float value) const
Add vector and float value.
Vector3 & operator/=(const float div)
Divide a vector by a value.
Vector3 Multiply(const ::Vector3 &vector3) const
Multiply vector by vector.
Vector3 Subtract(float value) const
Subtract vector by float value.
Vector3 operator-(const ::Vector3 &vector3) const
Subtract two vectors.
bool CheckCollision(float radius1, const ::Vector3 ¢er2, float radius2) const
Detect collision between two spheres.
Vector3 operator*(const float scaler) const
Multiply vector by scalar.
All raylib-cpp classes and functions appear in the raylib namespace.