-
Notifications
You must be signed in to change notification settings - Fork 1
/
plane_intersection.c
32 lines (28 loc) · 1.27 KB
/
plane_intersection.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* plane_intersection.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mghalmi <mghalmi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/28 10:50:12 by mghalmi #+# #+# */
/* Updated: 2024/02/08 13:08:48 by mghalmi ### ########.fr */
/* */
/* ************************************************************************** */
#include "main.h"
double solve_plane(t_point o, t_point d, t_point plane_p, t_point plane_nv)
{
double x;
double denom;
denom = dot(plane_nv, d);
if (denom == 0)
return (INFINITY);
x = (dot(plane_nv, vsubstr(plane_p, o))) / denom;
if (x > 0)
return (x);
return (INFINITY);
}
double plane_intersection(t_point o, t_point d, t_obj *lst)
{
return (solve_plane(o, d, lst->fig.pl.p, lst->normal));
}