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 3f110be

Browse files
author
Loic Mohin
committed
update both gits
1 parent 1cae01c commit 3f110be

File tree

15 files changed

+83
-39
lines changed

15 files changed

+83
-39
lines changed

‎Makefile‎

Lines changed: 2 additions & 2 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:29:00 by TheTerror #+# #+# #
9-
# Updated: 2024年02月13日 14:03:02 by TheTerror ### ########lyon.fr #
9+
# Updated: 2024年02月13日 15:02:25 by lmohin ### ########.fr #
1010
# #
1111
# **************************************************************************** #
1212

@@ -43,7 +43,7 @@ SRC_MATHTOOLS = $(addprefix $(MATHTOOLS_PATH), converts.c vectors.c subtractions
4343
SRC_MEMTOOLS = $(addprefix $(MEMTOOLS_PATH), initmem.c freemem.c init_elms.c free_elms.c)
4444
SRC_OTHERS = $(addprefix $(OTHERS_PATH), utils.c display.c)
4545
SRC_PARSING = $(addprefix $(PARSING_PATH), utils.c parsing.c ambient.c camera.c light.c \
46-
sphere.c sphere_utils.c plane.c plane_utils.c cylindre.c cylinder_utils.c)
46+
sphere.c sphere_utils.c plane.c plane_utils.c cylinder.c cylinder_utils.c)
4747
SRC_RAYS = $(addprefix $(RAYS_PATH), ray.c)
4848
SRC_LIGHTNING = $(addprefix $(LIGHTNING_PATH), lightning.c cylinder_lightning.c sphere_lightning.c plane_lightning.c shadows.c light_color.c)
4949

‎README.md‎

Lines changed: 0 additions & 1 deletion
This file was deleted.

‎inters/cy_extremities.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
/* By: TheTerror <jfaye@student.42lyon.fr> +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
88
/* Created: 2024年02月04日 14:38:21 by TheTerror #+# #+# */
9-
/* Updated: 2024年02月13日 14:28:03 by TheTerror ### ########lyon.fr */
9+
/* Updated: 2024年02月13日 17:56:25 by lmohin ### ########.fr */
1010
/* */
1111
/* ************************************************************************** */
1212

@@ -80,7 +80,7 @@ t_bool compute_lenght_t(t_ray *ray, t_cy *cy, t_cyvars *vars)
8080

8181
t_bool compute_norm_vec_phpi(t_ray *ray, t_cyvars *vars)
8282
{
83-
vars->norm_phpi = sqrt(__sq(vars->t * ray->dir.x + vars->c1) \
83+
vars->norm_phpi = __sqrt(__sq(vars->t * ray->dir.x + vars->c1) \
8484
+ __sq(vars->t * ray->dir.y + vars->c2) + __sq(vars->t \
8585
* ray->dir.z + vars->c3));
8686
return (__TRUE);

‎inters/ray_cylinder_utils.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
/* By: TheTerror <jfaye@student.42lyon.fr> +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
88
/* Created: 2024年02月11日 14:25:04 by TheTerror #+# #+# */
9-
/* Updated: 2024/02/11 15:06:14 by TheTerror ### ########lyon.fr */
9+
/* Updated: 2024/02/13 17:57:10 by lmohin ### ########.fr */
1010
/* */
1111
/* ************************************************************************** */
1212

@@ -33,8 +33,8 @@ t_bool setallparameters(t_ray *ray, t_cy *cy, t_params *xp)
3333
setparams_term2_term3(ray, xp);
3434
xp->c += xp->e - (xp->k * __sq(cy->r));
3535
xp->delta = __sq(xp->b) - (4 * xp->a * xp->c);
36-
xp->t1 = (-xp->b - sqrt(xp->delta)) / (2 * xp->a);
37-
xp->t2 = (-xp->b + sqrt(xp->delta)) / (2 * xp->a);
36+
xp->t1 = (-xp->b - __sqrt(xp->delta)) / (2 * xp->a);
37+
xp->t2 = (-xp->b + __sqrt(xp->delta)) / (2 * xp->a);
3838
return (__TRUE);
3939
}
4040

@@ -94,7 +94,7 @@ double computeheight_inters(t_ray *ray, t_cy *cy, double t)
9494
op.x = p.x - cy->o.x;
9595
op.y = p.y - cy->o.y;
9696
op.z = p.z - cy->o.z;
97-
hp = sqrt(__sq(vectornorm(&op)) - __sq(cy->r));
97+
hp = __sqrt(__sq(vectornorm(&op)) - __sq(cy->r));
9898
if (!vecdotvec(&op, &cy->axis))
9999
hp = 0;
100100
if (hp > cy->h / 2)

‎inters/ray_sphere.c‎

Lines changed: 3 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月23日 20:19:01 by TheTerror #+# #+# */
9-
/* Updated: 2024年02月13日 14:28:29 by TheTerror ### ########lyon.fr */
9+
/* Updated: 2024年02月13日 17:57:31 by lmohin ### ########.fr */
1010
/* */
1111
/* ************************************************************************** */
1212

@@ -65,8 +65,8 @@ double ray_inter_sp_op(t_ray *ray, t_sp *sp)
6565
vars.delta = __sq(vars.b) - (4 * vars.a * vars.c);
6666
if (vars.delta < 0)
6767
return (vars.delta);
68-
vars.s1 = (-vars.b - sqrt(vars.delta)) / (2 * vars.a);
69-
vars.s2 = (-vars.b + sqrt(vars.delta)) / (2 * vars.a);
68+
vars.s1 = (-vars.b - __sqrt(vars.delta)) / (2 * vars.a);
69+
vars.s2 = (-vars.b + __sqrt(vars.delta)) / (2 * vars.a);
7070
return (assess_the_solution(vars.s1, vars.s2));
7171
}
7272

‎lightning/cylinder_lightning.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
/* By: TheTerror <jfaye@student.42lyon.fr> +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
88
/* Created: 2024年02月07日 15:06:58 by lmohin #+# #+# */
9-
/* Updated: 2024/02/11 16:16:59 by TheTerror ### ########lyon.fr */
9+
/* Updated: 2024/02/13 17:57:49 by lmohin ### ########.fr */
1010
/* */
1111
/* ************************************************************************** */
1212

@@ -69,13 +69,13 @@ t_vec get_normal_cylinder(t_cy cylinder, t_ray main_ray)
6969
return (normal_cy);
7070
normal_cy.x = main_ray.o.x + main_ray.len * main_ray.dir.x;
7171
normal_cy.x -= (cylinder.o.x + cylinder.h / 2 * (-1) * cylinder.axis.x \
72-
+ sqrt(dist_center - __sq(cylinder.r)) * cylinder.axis.x);
72+
+ __sqrt(dist_center - __sq(cylinder.r)) * cylinder.axis.x);
7373
normal_cy.y = main_ray.o.y + main_ray.len * main_ray.dir.y;
7474
normal_cy.y -= (cylinder.o.y + cylinder.h / 2 * (-1) * cylinder.axis.y \
75-
+ sqrt(dist_center - __sq(cylinder.r)) * cylinder.axis.y);
75+
+ __sqrt(dist_center - __sq(cylinder.r)) * cylinder.axis.y);
7676
normal_cy.z = main_ray.o.z + main_ray.len * main_ray.dir.z;
7777
normal_cy.z -= (cylinder.o.z + cylinder.h / 2 * (-1) * cylinder.axis.z \
78-
+ sqrt(dist_center - __sq(cylinder.r)) * cylinder.axis.z);
78+
+ __sqrt(dist_center - __sq(cylinder.r)) * cylinder.axis.z);
7979
vectornormalize(&normal_cy, &normal_cy);
8080
return (normal_cy);
8181
}

‎mathtools/square.c‎

Lines changed: 11 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: 2024年02月10日 16:50:05 by TheTerror #+# #+# */
9-
/* Updated: 2024/02/10 16:50:54 by TheTerror ### ########lyon.fr */
9+
/* Updated: 2024/02/13 17:55:52 by lmohin ### ########.fr */
1010
/* */
1111
/* ************************************************************************** */
1212

@@ -16,3 +16,13 @@ double __sq(double n)
1616
{
1717
return (n * n);
1818
}
19+
20+
double __sqrt(double n)
21+
{
22+
if (n <= 0.000001 && n >= -0.000001)
23+
return (0);
24+
else if (n < 0)
25+
return (0);
26+
else
27+
return (sqrt(n));
28+
}

‎mathtools/vectors.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
/* By: TheTerror <jfaye@student.42lyon.fr> +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
88
/* Created: 2023年08月17日 20:30:44 by TheTerror #+# #+# */
9-
/* Updated: 2024/02/10 16:31:42 by TheTerror ### ########lyon.fr */
9+
/* Updated: 2024/02/13 17:59:02 by lmohin ### ########.fr */
1010
/* */
1111
/* ************************************************************************** */
1212

1313
#include "mathtools.h"
1414

1515
double vectornorm(t_vec *vector)
1616
{
17-
return (sqrt(vectornormsqr(vector)));
17+
return (__sqrt(vectornormsqr(vector)));
1818
}
1919

2020
void setvec_coords(t_vec *vector)

‎miniRT.pdf‎

-8.02 MB
Binary file not shown.

‎parsing/cylindre.c‎ renamed to ‎parsing/cylinder.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* ************************************************************************** */
22
/* */
33
/* ::: :::::::: */
4-
/* cylindre.c :+: :+: :+: */
4+
/* cylinder.c :+: :+: :+: */
55
/* +:+ +:+ +:+ */
66
/* By: TheTerror <jfaye@student.42lyon.fr> +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */

0 commit comments

Comments
(0)

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