34 lines
1.2 KiB
C
34 lines
1.2 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* calcul_de_vecteur2.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: yantoine <yantoine@student.42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2025/02/13 20:59:38 by yantoine #+# #+# */
|
|
/* Updated: 2025/02/13 21:08:27 by yantoine ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "miniRT.h"
|
|
|
|
float vec3_length(t_vec3 a)
|
|
{
|
|
return (sqrtf(vec3_dot(a, a)));
|
|
}
|
|
|
|
t_vec3 vec3_normalize(t_vec3 a)
|
|
{
|
|
float len;
|
|
|
|
len = vec3_length(a);
|
|
if (len > 0)
|
|
return (vec3_scale(a, 1.0f / len));
|
|
return (a);
|
|
}
|
|
|
|
t_vec3 vec3_mul(t_vec3 a, t_vec3 b)
|
|
{
|
|
return ((t_vec3){a.x * b.x, a.y * b.y, a.z * b.z});
|
|
}
|