Capycore Engine  0.1.0
A simple and lightweight game engine written in C++ based on the Unity API architecture.
Loading...
Searching...
No Matches
physics_math.h
Go to the documentation of this file.
1#pragma once
2
3#include <box2d/box2d.h>
7
16namespace PhysicsMath {
17static constexpr float pi = B2_PI;
18static constexpr float circle_divisor = 180.0f;
19
21float to_meters(float pixels, float ratio) noexcept;
22
24float to_pixels(float meters, float ratio) noexcept;
25
27float to_radians(float degrees) noexcept;
28
30float to_degrees(float radians) noexcept;
31
33float convert_box2d_angle_to_radians(float sine, float cosine) noexcept;
34
36float convert_radians_to_box2d_sine(float radians) noexcept;
37
39float convert_radians_to_box2d_cosine(float radians) noexcept;
40
42float distance_between_points(const Point& a, const Point& b) noexcept;
43
45float dx_between_points(const Point& a, const Point& b) noexcept;
46
48float dy_between_points(const Point& a, const Point& b) noexcept;
49
52
54Vector3 vec3_to_box2d_vec3(const Vector3& v, bool from_pixels = true);
55
57float box2d_to_pixels(float length) noexcept;
58
60float pixels_to_box2d(float length) noexcept;
61
64 float height) noexcept;
65}; // namespace PhysicsMath
Represents a point in 2D space.
Definition point.h:6
Represents a 3D vector with x, y, and z components. This class provides basic vector operations such ...
Definition vector3.h:8
Namespace containing mathematical utility functions for physics calculations.
Definition physics_math.h:16
float to_meters(float pixels, float ratio) noexcept
Convert pixels to meters using the specified ratio.
float convert_box2d_angle_to_radians(float sine, float cosine) noexcept
Convert Box2D angle representation (sine, cosine) to radians.
float to_radians(float degrees) noexcept
Convert degrees to radians.
float to_degrees(float radians) noexcept
Convert radians to degrees.
float dy_between_points(const Point &a, const Point &b) noexcept
Calculate the difference in y-coordinates between two 2D points.
float pixels_to_box2d(float length) noexcept
Convert length from pixels to Box2D units.
Vector3 box2d_vec_to_pixel_vec3(const Vector3 &v, bool to_pixels=true)
Convert a Vector3 to Box2D vector representation.
float convert_radians_to_box2d_cosine(float radians) noexcept
Convert radians to Box2D cosine value.
float box2d_to_pixels(float length) noexcept
Convert length from Box2D units to pixels.
Vector3 physics_vec3_to_transform_pixel_vec3(const Vector3 &v, float width, float height) noexcept
Convert physics Vector3 to transform pixel Vector3.
float convert_radians_to_box2d_sine(float radians) noexcept
Convert radians to Box2D sine value.
float distance_between_points(const Point &a, const Point &b) noexcept
Calculate the distance between two 2D points.
Vector3 vec3_to_box2d_vec3(const Vector3 &v, bool from_pixels=true)
Convert a Box2D vector representation to Vector3.
float to_pixels(float meters, float ratio) noexcept
Convert meters to pixels using the specified ratio.
float dx_between_points(const Point &a, const Point &b) noexcept
Calculate the difference in x-coordinates between two 2D points.