Skip to content

Commit

Permalink
Updating math stuff.
Browse files Browse the repository at this point in the history
  • Loading branch information
Chukobyte committed Jan 6, 2024
1 parent 4230340 commit 0456143
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
8 changes: 8 additions & 0 deletions seika/math/se_math.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ SKAVector2 ska_math_vec2_lerp(const SKAVector2* v1, const SKAVector2* v2, float
};
}

float ska_math_vec2_angle(const SKAVector2* v) {
float angle = atan2f(v->y, v->x);
if (angle < 0.0f) {
angle += 2.0f * SKA_PI;
}
return angle;
}

// --- Rect2 --- //
bool se_rect2_does_rectangles_overlap(const SKARect2* sourceRect, const SKARect2* targetRect) {
return (sourceRect->x + sourceRect->w >= targetRect->x) &&
Expand Down
9 changes: 5 additions & 4 deletions seika/math/se_math.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ extern "C" {
#include "../utils/se_macro_util.h"

#define SKA_PI 3.14159265358979323846f
#define SKA_RAD_2_DEG(RADIANS) ((RADIANS) * 0.0174532925)
#define SKA_RAD_2_DEGF(RADIANS) ((RADIANS) * 0.0174532925f)
#define SKA_DEG_2_RAD(DEGREES) ((DEGREES) * 57.2957795)
#define SKA_DEG_2_RADF(DEGREES) ((DEGREES) * 57.2957795f)
#define SKA_RAD_2_DEG(RADIANS) ((RADIANS) * (180.0 / (double)SKA_PI))
#define SKA_RAD_2_DEGF(RADIANS) ((RADIANS) * (180.0f / SKA_PI))
#define SKA_DEG_2_RAD(DEGREES) ((DEGREES) * ((double)SKA_PI / 180.0))
#define SKA_DEG_2_RADF(DEGREES) ((DEGREES) * (SKA_PI / 180.0f))


// --- SKAVector2 --- //
Expand All @@ -34,6 +34,7 @@ typedef struct SKAVector2 {

bool ska_math_vec2_equals(const SKAVector2* v1, const SKAVector2* v2);
SKAVector2 ska_math_vec2_lerp(const SKAVector2* v1, const SKAVector2* v2, float t);
float ska_math_vec2_angle(const SKAVector2* v);

// --- SKAVector2i --- //
typedef struct SKAVector2i {
Expand Down
2 changes: 1 addition & 1 deletion vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "seika",
"version": "0.0.22",
"version": "0.0.23",
"dependencies": [
{
"name": "sdl2",
Expand Down

0 comments on commit 0456143

Please sign in to comment.