first commit
This commit is contained in:
55
BSQ/srcs/algo/algo.c
Normal file
55
BSQ/srcs/algo/algo.c
Normal file
@ -0,0 +1,55 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* algo.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/08/01 22:03:23 by axdubois #+# #+# */
|
||||
/* Updated: 2023/08/02 20:32:48 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../../includes/algo-h/algo.h"
|
||||
#include "../../includes/utils-h/utils.h"
|
||||
|
||||
int ft_is_side_max(int x, int y, int mx, int my)
|
||||
{
|
||||
int l;
|
||||
|
||||
l = (mx - x) - (my - y);
|
||||
if (l > 0)
|
||||
return (mx - x);
|
||||
else if (l < 0)
|
||||
return (my - y);
|
||||
else
|
||||
return (0);
|
||||
}
|
||||
|
||||
t_square ft_comb(t_coords *listobjsx, t_coords *listobjsy)
|
||||
{
|
||||
int i;
|
||||
int j;
|
||||
t_square square_max;
|
||||
|
||||
square_max.x = 0;
|
||||
square_max.y = 0;
|
||||
square_max.side = 0;
|
||||
i = -1;
|
||||
j = -1;
|
||||
while (listobjsx[++i].x > -1)
|
||||
{
|
||||
while (listobjsy[++j].y > -1)
|
||||
{
|
||||
if ((square_max.x - listobjsx[i].x) < 0
|
||||
&& (square_max.y - listobjsy[j].y) < 0)
|
||||
{
|
||||
square_max.x = listobjsx[i].x;
|
||||
square_max.y = listobjsy[i].y;
|
||||
square_max.side = ft_is_side_max(listobjsx[i].x,
|
||||
listobjsy[j].y, square_max.x, square_max.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
return (square_max);
|
||||
}
|
Reference in New Issue
Block a user