예제 #1
0
파일: opticator.c 프로젝트: gabfou/RT
double			trans_calculator(t_thr *f, t_inter *inter,
	t_transroi *n, t_pd *pd)
{
	FLOAT_SIZE	scalc;
	FLOAT_SIZE	angle;
	t_vec		t;

	t.x = 0;
	t.y = 0;
	t.z = 0;
	angle = 0;
	scalc = 0;
	angle = M_PI_2 - acos(dot_prod(pd->dir, inter->norm));
	angle = (angle > 0) ? -angle : angle;
	if (sin(angle) > (AIR_INCI / GLASS_INCI))
		return (1);
	scalc = carre(AIR_INCI / GLASS_INCI) * carre(1 - carre(cos(angle)));
	t.x = ((AIR_INCI / GLASS_INCI) * pd->dir.x) + ((AIR_INCI / GLASS_INCI)
		* cos(angle) - fabs(1 - scalc)) * inter->norm.x;
	t.y = ((AIR_INCI / GLASS_INCI) * pd->dir.y) + ((AIR_INCI / GLASS_INCI)
		* cos(angle) - fabs(1 - scalc)) * inter->norm.y;
	t.z = ((AIR_INCI / GLASS_INCI) * pd->dir.z) + ((AIR_INCI / GLASS_INCI)
		* cos(angle) - fabs(1 - scalc)) * inter->norm.z;
	n->transpd.dir = normalizator_ret(t);
	n->transpd.pos = inter->pos;
	impactor(f->env, &n->transpd, f, &n->transinter);
	return (0);
}
예제 #2
0
파일: calc2.c 프로젝트: gabfou/RT
void				normalizator(t_vec *vec)
{
	long double	lenght;

	lenght = sqrt(carre(vec->x) + carre(vec->y) + carre(vec->z));
	if (lenght == 0.0)
		ft_putendl("i just saved the universe!");
	vec->x = vec->x / lenght;
	vec->y = vec->y / lenght;
	vec->z = vec->z / lenght;
}
예제 #3
0
파일: calc2.c 프로젝트: gabfou/RT
t_vec				normalizator_ret(t_vec vec)
{
	long double	lenght;

	lenght = sqrt(carre(vec.x) + carre(vec.y) + carre(vec.z));
	if (lenght == 0.0)
		ft_putendl("i just saved the universe!");
	vec.x = vec.x / lenght;
	vec.y = vec.y / lenght;
	vec.z = vec.z / lenght;
	return (vec);
}
예제 #4
0
파일: sphere.c 프로젝트: gabfou/RT
void		check_sphere(t_item *item, t_pd *s, t_inter *inter, int impactmod)
{
	FLOAT_SIZE	a;
	FLOAT_SIZE	b;
	FLOAT_SIZE	c;
	FLOAT_SIZE	del;
	FLOAT_SIZE	t;

	(void)impactmod;
	a = carre(s->dir.x) + carre(s->dir.y) + carre(s->dir.z);
	b = 2 * (s->dir.x * (s->pos.x - item->sp->c.x) + s->dir.y
	* (s->pos.y - item->sp->c.y) + s->dir.z * (s->pos.z - item->sp->c.z));
	c = (carre(s->pos.x - item->sp->c.x) + carre(s->pos.y - item->sp->c.y) +
		carre(s->pos.z - item->sp->c.z)) - carre(item->sp->ray);
	del = carre(b) - (4 * a * c);
	if (del > 0)
	{
		t = ft_minspe((-b - sqrt(del)) / (2 * a), (-b + sqrt(del)) / (2 * a));
		if (check_t(inter, t, s, item) == 1 && 1)
		{
			set_normal_sphere(inter, item);
			if (item->texture)
				set_texture_sphere(inter, item);
		}
	}
	return ;
}
예제 #5
0
calcBezier::calcBezier(Geometry::Point3D p0i, Geometry::Point3D p1i, Geometry::Point3D p2i, Geometry::Point3D p3i, double nbPoints):
    p0(p0i), p1(p1i), p2(p2i), p3(p3i)
{
    m_tabPoints.reserve(nbPoints);

    // (1-t)^3 * P0 + 3(1-t)²*t * P1 + 3(1-t)t² * P2 + t^3 * P3
    for ( int i = 0 ; i <= nbPoints ; i++)
    {
        double t = i * 1.d/nbPoints;
        double tt  = 1 - t;
        Geometry::Point3D p;
        p.setX(cube(tt)*p0.getX() + 3*carre(tt)*p1.getX()*t + 3*carre(t)*tt*p2.getX() + cube(t)*p3.getX());
        p.setY(cube(tt)*p0.getY() + 3*carre(tt)*p1.getY()*t + 3*carre(t)*tt*p2.getY() + cube(t)*p3.getY());
        m_tabPoints.push_back(p);
    }
}
예제 #6
0
파일: opticator.c 프로젝트: gabfou/RT
double			get_schlick(t_pd *pd, t_inter *inter)
{
	double	ro;
	double	cosi;
	double	cost;

	ro = carre(AIR_INCI - GLASS_INCI / AIR_INCI + GLASS_INCI);
	cosi = dot_prod(vec_mult(pd->dir, -1), inter->norm);
	cost = fabs(1 - (carre(AIR_INCI / GLASS_INCI) * (1 - carre(cosi))));
	if (AIR_INCI <= GLASS_INCI)
		return (ro + (1 - ro) * pow(1 - cosi, 5));
	else if (AIR_INCI > GLASS_INCI)
		return (ro + (1 - ro) * pow(1 - cost, 5));
	else
		return (1);
}
예제 #7
0
void garderPointage(Jet jet, Pointage* feuilleScore, char figure)
{        
    switch (figure)
    {
        case '1':
            feuilleScore->un = nbDeFace(jet,UN); 
            break;
        case '2':
            feuilleScore->deux = nbDeFace(jet,DEUX);
            break;
        case '3':
            feuilleScore->trois = nbDeFace(jet,TROIS);
            break;
        case '4':
            feuilleScore->quatre = nbDeFace(jet,QUATRE);
            break;
        case '5':
            feuilleScore->cinq = nbDeFace(jet,CINQ);
            break;
        case '6':
            feuilleScore->six = nbDeFace(jet,SIX);             
            break;
        case 'b':
        case 'B':
            feuilleScore->brelan = brelan(jet);             
            break;
        case 'c':
        case 'C':
            feuilleScore->carre = carre(jet);             
            break;
        case 'm':
        case 'M':
            feuilleScore->mainPleine = mainPleine(jet);             
            break;
        case 'p':
        case 'P':
            feuilleScore->pSuite = petiteSuite(jet);             
            break;
        case 'g':
        case 'G':
            feuilleScore->gSuite = grandeSuite(jet);      
            break;
        case 'y':
        case 'Y':
            feuilleScore->yahtzee = yahtzee(jet);             
            break;
        case 'h':
        case 'H':
            feuilleScore->chance = chance(jet);             
            break;
    }
}
예제 #8
0
파일: calc5.c 프로젝트: gabfou/RT
t_vec	trans_calculator_ret(t_inter *inter, t_pd *pd)
{
	FLOAT_SIZE	scalc;
	FLOAT_SIZE	angle;
	t_vec		t;

	t.x = 0;
	t.y = 0;
	t.z = 0;
	angle = 0;
	scalc = 0;
	angle = M_PI_2 - acos(dot_prod(pd->dir, inter->norm));
	angle = (angle > 0) ? -angle : angle;
	scalc = carre(AIR_INCI / GLASS_INCI) * carre(1 - carre(cos(angle)));
	t.x = ((AIR_INCI / GLASS_INCI) * pd->dir.x) + ((AIR_INCI / GLASS_INCI)
		* cos(angle) - fabs(1 - scalc)) * inter->norm.x;
	t.y = ((AIR_INCI / GLASS_INCI) * pd->dir.y) + ((AIR_INCI / GLASS_INCI)
		* cos(angle) - fabs(1 - scalc)) * inter->norm.y;
	t.z = ((AIR_INCI / GLASS_INCI) * pd->dir.z) + ((AIR_INCI / GLASS_INCI)
		* cos(angle) - fabs(1 - scalc)) * inter->norm.z;
	return (normalizator_ret(t));
}
예제 #9
0
void imprimerScoresPossibles(Jet jet)
{
  printf("**********************************************\n");
  printf("*    QUEL POINTAGE VOULEZ-VOUS GARDER?       *\n");
  printf("**********************************************\n");
  printf("*     (1) : %2d       *       (B)relan = %2d   *\n", nbDeFace(jet,UN), brelan(jet));
  printf("*     (2) : %2d       *        (C)arré = %2d   *\n", nbDeFace(jet,DEUX), carre(jet));
  printf("*     (3) : %2d       *  (M)ain Pleine = %2d   *\n", nbDeFace(jet,TROIS), mainPleine(jet));
  printf("*     (4) : %2d       * (P)etite suite = %2d   *\n", nbDeFace(jet,QUATRE), petiteSuite(jet));
  printf("*     (5) : %2d       * (G)rande suite = %2d   *\n", nbDeFace(jet,CINQ), grandeSuite(jet));
  printf("*     (6) : %2d       *      (Y)ahtzee = %2d   *\n", nbDeFace(jet,SIX), yahtzee(jet));
  printf("*                    *       C(h)ance = %2d   *\n", chance(jet));
  printf("**********************************************\n");
}
예제 #10
0
파일: fdf1_base.c 프로젝트: Antecs/fildefer
void	fdf_base(int x, int y, int nbr_x, int nbr_y, t_bunny_pixelarray *pix)
{
  t_carre base;
  unsigned int color;
  int	test;

  test = 0;
  int	length;
  int	width;
  int	x_memo;
  
  length = 0;
  width= 0;
  
  base.origin.y = 0;
  base.origin.x = 0;
  x_memo = 0;
  base.x = x;
  base.y = y;

  while (width < nbr_y)
    {
      while (length < nbr_x)
	{
	  carre(base, pix, color,test);
	  base.origin.x += x;
	  length++;
	}
      length = 0;
      base.origin.x = x_memo;
      base.origin.y = base.y;
      base.y += y;
      base.x += x;
      test = 1;
      //  x_memo = x_memo + 70;

       width++;
    }
}
예제 #11
0
파일: calc.c 프로젝트: gabfou/RT
inline FLOAT_SIZE	get_dist(const t_vec v1, const t_vec v2)
{
	return (sqrt(carre(v2.x - v1.x) + carre(v2.y - v1.y) + carre(v2.z - v1.z)));
}
void RandomIA::step(){
        carre();
}