Example #1
0
void	ft_set_parallel(t_map *map)
{
	int		i;
	int		j;
	t_line	d;

	i = -1;
	while (++i < map->lines && !(j = 0))
		while (j < map->columns)
		{
			map->map[i][j].x1 = map->zoom * (j - map->columns / 2);
			map->map[i][j].y1 = map->zoom * (i - map->lines / 2);
			map->map[i][j].h = map->map[i][j].h1 * map->height;
			ft_rotate(&map->map[i][j], map->axis[0].axis, map->axis[0].value);
			ft_rotate(&map->map[i][j], map->axis[1].axis, map->axis[1].value);
			ft_rotate(&map->map[i][j], map->axis[2].axis, map->axis[2].value);
			d.a = map->map[i][j].x1 - map->eye.x;
			d.b = map->map[i][j].y1 - map->eye.y;
			d.c = map->map[i][j].h - map->eye.h;
			map->map[i][j].x = (d.a / (float)d.c) *
				(map->win_h - map->eye.h) + map->eye.x;
			map->map[i][j].y = (d.b / (float)d.c) *
				(map->win_h - map->eye.h) + map->eye.y;
			map->map[i][j].x += map->win_width / 2 + map->trans.x;
			map->map[i][j].y += map->win_length / 2 + map->trans.y;
			j++;
		}
}
Example #2
0
static void	ft_while_r(t_info *info, int min)
{
	int	i;

	i = 0;
	if (ft_sort_test_pa(info))
		return ;
	while (min != SSIZEA - 1)
	{
		ft_rotate(SIPA, info);
		min++;
	}
}
Example #3
0
File: draw.c Project: happivlee/fdf
void	ft_draw(t_env *fdf, t_hooks *hooks)
{
	int			x;
	int			y;
	t_bresen	*breezy;

	x = 0;
	y = 0;
	breezy = (t_bresen *)malloc(sizeof(t_bresen));
	ft_rotate(fdf, hooks);
	ft_translate(&fdf, hooks);
	ft_drawright(fdf, &breezy, hooks);
	ft_drawdown(fdf, &breezy, hooks);
}
Example #4
0
t_vector		cone_norme(t_obj *obj, t_vector pos, t_scene *sc)
{
	t_vector	norme;
	t_vector	rot;

	rot.x = sc->rot.x + obj->rot.x;
	rot.y = sc->rot.y + obj->rot.y;
	rot.z = sc->rot.z + obj->rot.z;
	pos = ft_rotate(pos, &rot);
	norme.x = pos.x - obj->pos.x;
	norme.y = pos.y - obj->pos.y;
	norme.z = pos.z - obj->pos.z;
	return (norme);
}
Example #5
0
double			ft_cone(t_obj *obj, t_vector vec, t_scene *sc)
{
	t_eq		eq;
	t_vector	rot;

	rot.x = sc->rot.x + obj->rot.x;
	rot.y = sc->rot.y + obj->rot.y;
	rot.z = sc->rot.z + obj->rot.z;
	vec = ft_rotate(vec, &rot);
	eq = ft_inter_cone(obj, vec);
	if (eq.t1 > eq.t2 && eq.t2 > 0)
		return (eq.t2);
	else if (eq.t1 < eq.t2 && eq.t1 > 0)
		return (eq.t1);
	return (0);
}
Example #6
0
static t_eq		ft_inter_cone(t_obj *obj, t_vector vec)
{
	t_eq		eq;
	t_vector	vec2;

	vec2.x = obj->pos.x;
	vec2.y = obj->pos.y;
	vec2.z = obj->pos.z;
	vec2 = ft_rotate(vec2, &obj->rot);
	eq.a = pow(vec.y, 2) + pow(vec.z, 2) - pow(vec.x, 2);
	eq.b = (2 * vec.y * -vec2.y) + (2 * vec.z * -vec2.z);
	eq.b -= (2 * vec.x * -vec2.x);
	eq.c = pow(vec2.y, 2) + pow(vec2.z, 2) - pow(vec2.x, 2);
	eq.res = pow(eq.b, 2) - (4 * eq.a * eq.c);
	eq.t1 = -1;
	eq.t2 = -1;
	if (eq.res >= 0)
	{
		eq.t1 = ((-eq.b) + sqrt(eq.res)) / (2 * eq.a);
		eq.t2 = ((-eq.b) - sqrt(eq.res)) / (2 * eq.a);
	}
	return (eq);
}