cub3d/src/math/rot.c
2025-05-14 16:14:27 +02:00

29 lines
1.2 KiB
C

/* ************************************************************************** */
/* */
/* :::::::: */
/* rot.c :+: :+: */
/* +:+ */
/* By: qmennen <qmennen@student.codam.nl> +#+ */
/* +#+ */
/* Created: 2025/04/25 10:35:58 by whaffman #+# #+# */
/* Updated: 2025/05/14 16:13:22 by whaffman ######## odam.nl */
/* */
/* ************************************************************************** */
#include "cub3d.h"
#include "math.h"
#include "vec_math.h"
t_vec2 rot(t_vec2 a, double angle)
{
t_vec2 result;
double cos_angle;
double sin_angle;
cos_angle = cosf(angle);
sin_angle = sinf(angle);
result.x = a.x * cos_angle - a.y * sin_angle;
result.y = a.x * sin_angle + a.y * cos_angle;
return (result);
}