-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbs_size_adjust_bonus.c
52 lines (47 loc) · 1.89 KB
/
bs_size_adjust_bonus.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
48
49
50
51
52
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* bs_size_adjust_bonus.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: nkawaguc <nkawaguc@student.42tokyo.jp> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/30 20:58:30 by nkawaguc #+# #+# */
/* Updated: 2024/10/30 21:26:03 by nkawaguc ### ########.fr */
/* */
/* ************************************************************************** */
#include "bs_stl_bonus.h"
static void stl_update_zoom(t_stldata *stldata);
void stl_size_adjust(t_stldata *stldata)
{
int i;
int j;
stl_update_zoom(stldata);
i = -1;
while (++i < stldata->tris_idx)
{
j = -1;
while (++j < 3)
{
stldata->tris[i].p[j].x *= stldata->zoom;
stldata->tris[i].p[j].y *= stldata->zoom;
stldata->tris[i].p[j].z *= stldata->zoom;
}
}
stldata->x_max *= stldata->zoom;
stldata->x_min *= stldata->zoom;
stldata->y_max *= stldata->zoom;
stldata->y_min *= stldata->zoom;
}
static void stl_update_zoom(t_stldata *stldata)
{
if (stldata->x_max == stldata->x_min && stldata->y_max == stldata->y_min)
stldata->zoom = 1;
else if (stldata->x_max == stldata->x_min)
stldata->zoom = WIN_HEIGHT * 0.8 / (stldata->y_max - stldata->y_min);
else if (stldata->y_max == stldata->y_min)
stldata->zoom = WIN_WIDTH * 0.8 / (stldata->x_max - stldata->x_min);
else
stldata->zoom
= fdf_min(WIN_WIDTH * 0.8 / (stldata->x_max - stldata->x_min),
WIN_HEIGHT * 0.8 / (stldata->y_max - stldata->y_min));
}