separated the headers and c files properly
This commit is contained in:
1 parent
14152cb5a0
commit
f7e2d85e37
8 files changed
+173
-137
No files matched your search
+9
-31
@@ -1,43 +1,21 @@
|
||||
#pragma once
|
||||
#ifndef VEC_UTIL_H_
|
||||
#define VEC_UTIL_H_
|
||||
#include <math.h>
|
||||
#include <raylib.h>
|
||||
static const Vector2 NULL_VEC2 = {0, 0};
|
||||
|
||||
Vector2 transform_to_center(Vector2 v) {
|
||||
int width = GetRenderWidth();
|
||||
int height = GetRenderHeight();
|
||||
Vector2 result = {v.x + width / 2.0, v.y + height / 2.0};
|
||||
return result;
|
||||
}
|
||||
bool vec2_is_null(Vector2 v) ;
|
||||
|
||||
Vector2 vec2_sum(const Vector2 *a, const Vector2 *b) {
|
||||
Vector2 result = {a->x + b->x, a->y + b->y};
|
||||
return result;
|
||||
}
|
||||
Vector2 vec2_diff(const Vector2 *a, const Vector2 *b) {
|
||||
Vector2 result = {a->x - b->x, a->y - b->y};
|
||||
return result;
|
||||
}
|
||||
Vector2 transform_to_center(Vector2 v);
|
||||
Vector2 vec2_sum(const Vector2 *a, const Vector2 *b);
|
||||
float vec2_len(Vector2 v) ;
|
||||
|
||||
float vec2_len(Vector2 v) { return sqrtf(v.x * v.x + v.y * v.y); }
|
||||
Vector2 vec2_normalize(const Vector2 v) ;
|
||||
|
||||
Vector2 vec2_normalize(const Vector2 v) {
|
||||
float len = vec2_len(v);
|
||||
if (len == 0) {
|
||||
return NULL_VEC2;
|
||||
}
|
||||
Vector2 result = {v.x / len, v.y / len};
|
||||
return result;
|
||||
}
|
||||
Vector2 vec2_scale(const Vector2 *normal, const float len) ;
|
||||
|
||||
Vector2 vec2_scale(const Vector2 *normal, const float len) {
|
||||
Vector2 result = {len * normal->x, len * normal->y};
|
||||
return result;
|
||||
}
|
||||
|
||||
float vec2_dot(const Vector2 *a, const Vector2 *b) {
|
||||
return a->x * b->x + a->y * b->y;
|
||||
}
|
||||
float vec2_dot(const Vector2 *a, const Vector2 *b) ;
|
||||
Vector2 vec2_diff(const Vector2 *a, const Vector2 *b) ;
|
||||
|
||||
#endif // VEC_UTIL_H_
|
||||
Reference in new issue
Block a user