double ft_tan(double radian) { if (ft_cos(radian) != 0) return (ft_sin(radian) / ft_cos(radian)); else return (ft_sin(radian) / 0.0000001); }
void ft_place_dots_3(t_win w, t_dot *dot) { float x; float y; int i; while (dot) { i = -1; x = -((dot->x + dot->y) * w.zoom); y = -((dot->y - dot->x) * w.zoom - (dot->z * w.zoom * 2.7 * w.zoom_z)); while (i++ < w.zoom) { if (ft_dotnext(dot, w.x) && ft_dotnext(dot, w.x)->z == dot->z) mlx_pixel_put(w.mlx, w.window, (w.obj_x + w.max_x / 2) + (x - i), (w.obj_y) + (y - i) * ft_sin(30), (w.zoom_z != 0) ? dot->color : 16777215); if (dot->next && dot->x % w.x != 0 && dot->next->z == dot->z) mlx_pixel_put(w.mlx, w.window, (w.obj_x + w.max_x / 2) + (x - i), (w.obj_y) + (y + i) * ft_sin(30), (w.zoom_z != 0) ? dot->color : 16777215); } dot->x = lroundf((w.obj_x + w.max_x / 2) + (x)); dot->y = lroundf((w.obj_y) + (y) * ft_sin(30)); dot = dot->next; } }
t_pix *ft_get_h_inter(t_win *win, int x) { t_pix *pix; if ((!(pix = (t_pix*)malloc(sizeof(t_pix))))) ft_ferror(ERR_MALLOC); pix->ang = ft_get_alpha(win, x); if (pix->ang == 0 || pix->ang == 180) return (NULL); ft_set_h_inter(win, pix); pix->dist = ft_dist_corr(win, (CAM_Y - pix->y) / ft_sin(pix->ang), x); return (pix); }
void ft_key_up(t_win *win) { t_pix pix; t_pix *inter; inter = ft_get_shorter_inter(win, WIN_WIDTH / 2); pix.x = CAM_X + ft_cos(CAM_ANG) * M_RUN_SPD; pix.y = CAM_Y + ft_sin(CAM_ANG) * M_RUN_SPD; if (inter->dist > M_RUN_SPD) { CAM_X = pix.x; CAM_Y = pix.y; } free(inter); }
void draw_circle(t_bal *bal, t_env *e) { float angle; angle = 0.0; glBegin(GL_TRIANGLE_FAN); if (e->lives == 3) glColor3f(0.2, 0.9, 0.6); else if (e->lives == 2) glColor3f(0.9, 0.2, 0.6); else if (e->lives == 1) glColor3f(0.2, 0.6, 0.9); glVertex2f(bal->x1, bal->y1); while (angle <= 2 * 3.14159265) { bal->x2 = bal->x1 + ft_sin(angle) * bal->radius; bal->y2 = bal->y1 + ft_cos(angle) * bal->radius; glVertex2f(bal->x2, bal->y2); angle += 0.005; } glEnd(); }
double ft_tan(double angle) { if (angle == 90) return (2000000000); return (ft_sin(angle) / ft_cos(angle)); }