archeus/src/math/vector2.c

18 lines
496 B
C
Raw Normal View History

2023-01-30 23:23:03 -07:00
#include "arc/math/vector2.h"
#include <math.h>
void ARC_Vector2_Normalize(ARC_Vector2 *vector){
float length = sqrtf((vector->x * vector->x) + (vector->y * vector->y));
2023-06-25 22:14:32 -06:00
if(length == 0){
return;
}
2023-01-30 23:23:03 -07:00
vector->x /= length;
vector->y /= length;
2023-02-19 12:11:33 -07:00
}
void ARC_Vector2_RotateDegree(ARC_Vector2 *vector, float angle){
ARC_Vector2 temp = *vector;
vector->x = (temp.x * cos(angle)) - (temp.y * sin(angle));
vector->y = (temp.x * sin(angle)) + (temp.y * cos(angle));
2023-01-30 23:23:03 -07:00
}