-
Notifications
You must be signed in to change notification settings - Fork 0
/
project.c
47 lines (42 loc) · 1.71 KB
/
project.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* project.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhallama <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/14 14:58:40 by jhallama #+# #+# */
/* Updated: 2020/02/19 13:37:10 by jhallama ### ########.fr */
/* */
/* ************************************************************************** */
#include "fdf.h"
#include "libft/libft.h"
static t_point iso(t_point point, t_mlx *mlx)
{
int old_x;
int old_y;
old_x = point.x * mlx->ratio + BORDER;
old_y = point.y * mlx->ratio + BORDER;
point.x = (old_x - old_y) * cos(0.523598776) + WINDOW_W / 2 - 2 * BORDER;
point.y = (old_x + old_y) * sin(0.523598776) - point.z * mlx->flatten +
WINDOW_H / 3 - 2 * BORDER;
point.x += mlx->move_h;
point.y += mlx->move_v;
return (point);
}
static t_point top_down(t_point point, t_mlx *mlx)
{
point.x = point.x * mlx->ratio + BORDER;
point.y = point.y * mlx->ratio + BORDER - point.z * mlx->flatten;
point.x += mlx->move_h;
point.y += mlx->move_v;
return (point);
}
t_point project(t_point point, t_mlx *mlx)
{
if (mlx->projection == 1)
point = top_down(point, mlx);
if (mlx->projection == 0)
point = iso(point, mlx);
return (point);
}