diff --git a/inc/vec_math.h b/inc/vec_math.h index 20a83b2..7d15302 100644 --- a/inc/vec_math.h +++ b/inc/vec_math.h @@ -6,7 +6,7 @@ /* By: qmennen +#+ */ /* +#+ */ /* Created: 2025/04/25 10:11:44 by whaffman #+# #+# */ -/* Updated: 2025/05/11 13:36:45 by whaffman ######## odam.nl */ +/* Updated: 2025/05/12 11:04:28 by whaffman ######## odam.nl */ /* */ /* ************************************************************************** */ @@ -102,4 +102,20 @@ t_vec2 perp(t_vec2 a); */ t_vec2 rot_by_dir(t_vec2 vec, t_vec2 dir, t_vec2 axis); +/** + * @brief Converts a 2D vector to a 2D integer vector. + * + * @param vec The 2D vector to convert. + * @return The converted 2D integer vector. + */ +t_vec2_int vec2_to_int(t_vec2 vec); + +/** + * @brief Converts a 2D integer vector to a 2D vector. + * + * @param vec The 2D integer vector to convert. + * @return The converted 2D vector. + */ +t_vec2 vec2_from_int(t_vec2_int vec); + #endif // VEC_MATH_H \ No newline at end of file diff --git a/src/math/vec2_from_int.c b/src/math/vec2_from_int.c new file mode 100644 index 0000000..a2645cf --- /dev/null +++ b/src/math/vec2_from_int.c @@ -0,0 +1,22 @@ +/* ************************************************************************** */ +/* */ +/* :::::::: */ +/* vec2_from_int.c :+: :+: */ +/* +:+ */ +/* By: whaffman +#+ */ +/* +#+ */ +/* Created: 2025/05/12 11:03:47 by whaffman #+# #+# */ +/* Updated: 2025/05/12 11:03:58 by whaffman ######## odam.nl */ +/* */ +/* ************************************************************************** */ + +#include "cub3d.h" + +t_vec2 vec2_from_int(t_vec2_int vec) +{ + t_vec2 result; + + result.x = (double)vec.x; + result.y = (double)vec.y; + return (result); +} \ No newline at end of file diff --git a/src/math/vec2_to_int.c b/src/math/vec2_to_int.c new file mode 100644 index 0000000..c523660 --- /dev/null +++ b/src/math/vec2_to_int.c @@ -0,0 +1,22 @@ +/* ************************************************************************** */ +/* */ +/* :::::::: */ +/* vec2_to_int.c :+: :+: */ +/* +:+ */ +/* By: whaffman +#+ */ +/* +#+ */ +/* Created: 2025/05/12 11:02:49 by whaffman #+# #+# */ +/* Updated: 2025/05/12 11:03:27 by whaffman ######## odam.nl */ +/* */ +/* ************************************************************************** */ + +#include "cub3d.h" + +t_vec2_int vec2_to_int(t_vec2 vec) +{ + t_vec2_int result; + + result.x = (int)vec.x; + result.y = (int)vec.y; + return (result); +} \ No newline at end of file