-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdimension.c
60 lines (55 loc) · 1.93 KB
/
dimension.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
53
54
55
56
57
58
59
60
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* dimension.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: akinzeli <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/13 13:10:20 by akinzeli #+# #+# */
/* Updated: 2024/03/19 16:31:32 by akinzeli ### ########.fr */
/* */
/* ************************************************************************** */
#include "fdf.h"
#include <math.h>
void three_point(t_env *env)
{
int i;
i = 0;
env->init_dim = malloc(sizeof(t_init) * env->map_h * env->map_l);
if (!env->init_dim)
error_mes("Error Malloc");
env->y = 0;
while (env->y < env->map_h)
{
env->x = 0;
while (env->x < env->map_l)
{
env->init_dim[i] = (t_init){env->x, env->y,
env->final_map[env->y][env->x]};
i++;
env->x++;
}
env->y++;
}
free_tab(env);
}
void two_point(t_env *env)
{
int i;
i = 0;
env->final_dim = malloc(sizeof(t_final) * env->map_h * env->map_l);
if (!env->final_dim)
error_mes("Error Malloc");
while (i < (env->map_l * env->map_h))
{
env->final_dim[i].y = env->init_dim[i].y * cosf(env->angle)
+ env->init_dim[i].y * cosf(env->angle + 2) + (env->init_dim[i].z
* env->altitude) * cosf(env->angle - 2);
env->final_dim[i].x = env->init_dim[i].x * sinf(env->angle)
+ env->init_dim[i].y * sinf(env->angle + 2) + (env->init_dim[i].z
* env->altitude) * sinf(env->angle - 2);
env->final_dim[i].x *= -env->scale;
env->final_dim[i].y *= env->scale;
i++;
}
}