feat: add Cross2D for Kreuzprodukt vector calculation
This commit is contained in:
+15
-16
@@ -1,27 +1,26 @@
|
||||
#include "engine.h"
|
||||
|
||||
bool IsVectorZero(Vector2 v) {
|
||||
float epsilon = 0.01f;
|
||||
return (fabs(v.x) < epsilon && fabs(v.y) < epsilon);
|
||||
float epsilon = 0.01f;
|
||||
return (fabs(v.x) < epsilon && fabs(v.y) < epsilon);
|
||||
}
|
||||
|
||||
Vector2 GetRandomVector(const Rectangle bounds) {
|
||||
return (Vector2){
|
||||
bounds.x + (float)GetRandomValue(0, 10000) / 10000.0f * bounds.width,
|
||||
bounds.y + (float)GetRandomValue(0, 10000) / 10000.0f * bounds.height
|
||||
};
|
||||
return (Vector2){
|
||||
bounds.x + (float)GetRandomValue(0, 10000) / 10000.0f * bounds.width,
|
||||
bounds.y + (float)GetRandomValue(0, 10000) / 10000.0f * bounds.height};
|
||||
}
|
||||
|
||||
Vector2 RotationToVector2(float rotation)
|
||||
{
|
||||
float rad = rotation * (PI / 180.0f);
|
||||
Vector2 vec = { cosf(rad), sinf(rad) };
|
||||
return vec;
|
||||
Vector2 RotationToVector2(float rotation) {
|
||||
float rad = rotation * (PI / 180.0f);
|
||||
Vector2 vec = {cosf(rad), sinf(rad)};
|
||||
return vec;
|
||||
}
|
||||
|
||||
float Vector2ToRotation(Vector2 vec)
|
||||
{
|
||||
float rad = atan2f(vec.y, vec.x);
|
||||
float deg = rad * (180.0f / PI);
|
||||
return deg;
|
||||
float Vector2ToRotation(Vector2 vec) {
|
||||
float rad = atan2f(vec.y, vec.x);
|
||||
float deg = rad * (180.0f / PI);
|
||||
return deg;
|
||||
}
|
||||
|
||||
float Cross2D(Vector2 a, Vector2 b) { return a.x * b.y - a.y * b.x; }
|
||||
|
||||
Reference in New Issue
Block a user