25 lines
1.2 KiB
C
25 lines
1.2 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* :::::::: */
|
|
/* rot_by_dir.c :+: :+: */
|
|
/* +:+ */
|
|
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
|
/* +#+ */
|
|
/* Created: 2025/05/11 13:24:34 by whaffman #+# #+# */
|
|
/* Updated: 2025/05/14 16:13:25 by whaffman ######## odam.nl */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "cub3d.h"
|
|
|
|
t_vec2 rot_by_dir(t_vec2 vec, t_vec2 dir, t_vec2 axis)
|
|
{
|
|
const double sin_res = dir.x;
|
|
const double cos_res = -dir.y;
|
|
t_vec2 res;
|
|
|
|
res.x = axis.x + (vec.x - axis.x) * cos_res - (vec.y - axis.y) * sin_res;
|
|
res.y = axis.y + (vec.x - axis.x) * sin_res + (vec.y - axis.y) * cos_res;
|
|
return (res);
|
|
}
|