utils.c
1 /* ************************************************************************** */ 2 /* */ 3 /* ::: :::::::: */ 4 /* utils.c :+: :+: :+: */ 5 /* +:+ +:+ +:+ */ 6 /* By: gychoi <gychoi@student.42seoul.kr> +#+ +:+ +#+ */ 7 /* +#+#+#+#+#+ +#+ */ 8 /* Created: 2023/05/05 21:12:41 by gychoi #+# #+# */ 9 /* Updated: 2023/05/05 21:18:44 by gychoi ### ########.fr */ 10 /* */ 11 /* ************************************************************************** */ 12 13 #include "header.h" 14 #include <stdlib.h> 15 16 double clamp(double x, double min, double max) 17 { 18 if (x < min) 19 return (min); 20 if (x > max) 21 return (max); 22 return (x); 23 } 24 25 double rand_num(int anti) 26 { 27 if (anti == 0) 28 return (0); 29 return ((double)rand() / (double)RAND_MAX); 30 }