Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e7464e1

Browse files
08/21/23 save
1 parent 2088e43 commit e7464e1

File tree

7 files changed

+77
-8
lines changed

7 files changed

+77
-8
lines changed

‎Makefile‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# By: TheTerror <jfaye@student.42lyon.fr> +#+ +:+ +#+ #
77
# +#+#+#+#+#+ +#+ #
88
# Created: 2023年08月17日 16:29:00 by TheTerror #+# #+# #
9-
# Updated: 2023/08/20 17:40:52 by TheTerror ### ########lyon.fr #
9+
# Updated: 2023/08/21 20:25:26 by TheTerror ### ########lyon.fr #
1010
# #
1111
# **************************************************************************** #
1212

@@ -17,6 +17,7 @@ LIBFT_LIB = $(LIBFT_PATH)libft.a
1717
LIBFT_PATH = ./libft/
1818
OBJ_PATH = ./.objs/
1919
MEMTOOLS_PATH = ./memtools/
20+
MATHTOOLS_PATH = ./mathtools/
2021
PARSING_PATH = ./parsing/
2122

2223

@@ -30,6 +31,7 @@ MLX_LINK_OPTIONS = -Lmlx_linux -lmlx_Linux -L/usr/lib -Imlx_linux -lXext -lX11 -
3031
RM = rm -rf
3132

3233
SRC_MEMTOOLS = $(addprefix $(MEMTOOLS_PATH), initmem.c freemem.c init_elms.c free_elms.c)
34+
SRC_MATHTOOLS = $(addprefix $(MATHTOOLS_PATH), converts.c vectors.c subtractions.c products.c)
3335
SRC_PARSING = $(addprefix $(PARSING_PATH), parsing.c ambient.c camera.c light.c \
3436
sphere.c plane.c cylindre.c)
3537
SRC = main.c minirt.c ft_mlx_utils.c events.c utils.c display.c ft_atod.c $(SRC_MEMTOOLS) $(SRC_PARSING)

‎main.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
/* By: TheTerror <jfaye@student.42lyon.fr> +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
88
/* Created: 2023年08月17日 16:30:47 by TheTerror #+# #+# */
9-
/* Updated: 2023/08/20 22:56:22 by TheTerror ### ########lyon.fr */
9+
/* Updated: 2023/08/21 17:12:17 by TheTerror ### ########lyon.fr */
1010
/* */
1111
/* ************************************************************************** */
1212

@@ -16,13 +16,12 @@ int main(int argc, char **argv)
1616
{
1717
t_vars *v;
1818

19-
(void) argc;
20-
(void) argv;
2119
v = ft_init_v();
2220
if (!ft_parse(v, argc, argv))
2321
ft_exitprocss(v, EXIT_FAILURE);
2422
if (!ft_set_mlx(v))
2523
ft_exitprocss(v, EXIT_FAILURE);
24+
ft_minirt(v);
2625
ft_events(v);
2726
mlx_loop(v->xptr);
2827
return (0);

‎mathtools/converts.c‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/* ************************************************************************** */
2+
/* */
3+
/* ::: :::::::: */
4+
/* converts.c :+: :+: :+: */
5+
/* +:+ +:+ +:+ */
6+
/* By: TheTerror <jfaye@student.42lyon.fr> +#+ +:+ +#+ */
7+
/* +#+#+#+#+#+ +#+ */
8+
/* Created: 2023年08月21日 20:23:31 by TheTerror #+# #+# */
9+
/* Updated: 2023年08月21日 20:35:19 by TheTerror ### ########lyon.fr */
10+
/* */
11+
/* ************************************************************************** */
12+
13+
#include "mathtools.h"
14+
15+
double ft_degtorad(double alpha)
16+
{
17+
double pi;
18+
19+
pi = 3.14159265358979323846264338327950288;
20+
return ((alpha * pi) / 180);
21+
}
22+
23+
double ft_radtodeg(double alpha)
24+
{
25+
double pi;
26+
27+
pi = 3.14159265358979323846264338327950288;
28+
return ((alpha * 180) / pi);
29+
}

‎mathtools/mathtools.h‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
/* By: TheTerror <jfaye@student.42lyon.fr> +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
88
/* Created: 2023年08月18日 18:36:23 by TheTerror #+# #+# */
9-
/* Updated: 2023/08/18 18:54:38 by TheTerror ### ########lyon.fr */
9+
/* Updated: 2023/08/21 20:36:15 by TheTerror ### ########lyon.fr */
1010
/* */
1111
/* ************************************************************************** */
1212

@@ -22,5 +22,7 @@ void ft_setvec_coords(t_vec *vector);
2222
double ft_vecdotvec(t_vec *vec2, t_vec *vec1, const double angle);
2323
t_vec *ft_vecdotpt(t_vec *vector, t_coord *point);
2424
t_vec *ft_vecdotconst(t_vec *vector, const double k);
25+
double ft_degtorad(double alpha);
26+
double ft_radtodeg(double alpha);
2527

2628
#endif

‎minirt.c‎

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,43 @@
66
/* By: TheTerror <jfaye@student.42lyon.fr> +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
88
/* Created: 2023年08月17日 16:29:22 by TheTerror #+# #+# */
9-
/* Updated: 2023/08/17 16:29:36 by TheTerror ### ########lyon.fr */
9+
/* Updated: 2023/08/21 23:53:10 by TheTerror ### ########lyon.fr */
1010
/* */
1111
/* ************************************************************************** */
1212

1313
#include "minirt.h"
1414

15+
t_bool ft_minirt(t_vars *v)
16+
{
17+
int i;
18+
int j;
19+
20+
j = 0;
21+
while (j < _SIZE_Y)
22+
{
23+
i = 0;
24+
while (i < _SIZE_X)
25+
{
26+
ft_ray(v, i, j);
27+
ft_sphere(v);
28+
i++;
29+
}
30+
j++;
31+
}
32+
return (__TRUE);
33+
}
34+
35+
t_bool ft_ray(t_vars *v, int i, int j)
36+
{
37+
t_coord *origin;
38+
t_coord end;
39+
40+
origin = &v->c->pov;
41+
end.x = i - _SIZE_X / 2.00;
42+
end.y = j - _SIZE_Y / 2.00;
43+
end.z = _SIZE_X /(2.00 * tan(ft_degtorad(v->c->fov) / 2.00));
44+
v->ray.x = end.x - origin->x;
45+
v->ray.y = end.y - origin->y;
46+
v->ray.z = end.z - origin->z;
47+
return (__TRUE);
48+
}

‎minirt.h‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
/* By: TheTerror <jfaye@student.42lyon.fr> +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
88
/* Created: 2023年08月17日 16:29:48 by TheTerror #+# #+# */
9-
/* Updated: 2023/08/20 17:39:31 by TheTerror ### ########lyon.fr */
9+
/* Updated: 2023/08/21 17:07:11 by TheTerror ### ########lyon.fr */
1010
/* */
1111
/* ************************************************************************** */
1212

@@ -31,5 +31,7 @@ t_bool ft_error(char *str);
3131
t_bool ft_isnumber(const char *str);
3232
double ft_atod(const char *nptr);
3333
t_bool ft_displayelms(t_vars *v);
34+
t_bool ft_minirt(t_vars *v);
35+
void my_mlx_pixel_put(t_img *img, int x, int y, int color);
3436

3537
# endif

‎preprocss.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
/* By: TheTerror <jfaye@student.42lyon.fr> +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
88
/* Created: 2023年08月17日 16:41:14 by TheTerror #+# #+# */
9-
/* Updated: 2023/08/20 16:04:23 by TheTerror ### ########lyon.fr */
9+
/* Updated: 2023/08/21 20:25:30 by TheTerror ### ########lyon.fr */
1010
/* */
1111
/* ************************************************************************** */
1212

@@ -138,6 +138,7 @@ typedef struct s_variables
138138
t_sp **sp;
139139
t_pl **pl;
140140
t_cy **cy;
141+
t_vec ray;
141142
} t_vars;
142143

143144
#endif

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /