Exemple #1
0
void		ft_rotate_lum_lp(double pro[3], double pos[3],
								double ve2[3], t_obj *obj)
{
	pro[X] = 0;
	pro[Y] = 1;
	pro[Z] = 0;
	ft_rotate_pos_cyl(pro, obj);
	xrotate(pos, obj->coo2[X]);
	yrotate(pos, obj->coo2[Y]);
	zrotate(pos, obj->coo2[Z]);
	ve2[0] = -fabs((obj->coo[X] - pos[X]) * pro[X]);
	ve2[1] = -fabs((obj->coo[Y] - pos[Y]) * pro[Y]);
	ve2[2] = -fabs((obj->coo[Z] - pos[Z]) * pro[Z]);
}
Exemple #2
0
void	rotate(t_ba *ba, t_obj *obj, double ray[3], double cam[3])
{
	ray[X] = ba->cam->ray[X];
	ray[Y] = ba->cam->ray[Y];
	ray[Z] = ba->cam->ray[Z];
	cam[X] = ba->cam->pos[X] - obj->coo[X];
	cam[Y] = ba->cam->pos[Y] - obj->coo[Y];
	cam[Z] = ba->cam->pos[Z] - obj->coo[Z];
	if (obj->coo2[X] != 0)
	{
		xrotate(ray, obj->coo2[X]);
		xrotate(cam, obj->coo2[X]);
	}
	if (obj->coo2[Y] != 0)
	{
		yrotate(ray, obj->coo2[Y]);
		yrotate(cam, obj->coo2[Y]);
	}
	if (obj->coo2[Z] != 0)
	{
		zrotate(ray, obj->coo2[Z]);
		zrotate(cam, obj->coo2[Z]);
	}
}
static void
huerotate(float mat[3][3],		/* I - Matrix to append to */
          float rot)			/* I - Hue rotation in degrees */
{
  float hmat[3][3];			/* Hue matrix */
  float lx, ly, lz;			/* Luminance vector */
  float xrs, xrc;			/* X rotation sine/cosine */
  float yrs, yrc;			/* Y rotation sine/cosine */
  float zrs, zrc;			/* Z rotation sine/cosine */
  float zsx, zsy;			/* Z shear x/y */


 /*
  * Load the identity matrix...
  */

  ident(hmat);

 /*
  * Rotate the grey vector into positive Z...
  */

  xrs = M_SQRT1_2;
  xrc = M_SQRT1_2;
  xrotate(hmat,xrs,xrc);

  yrs = -1.0 / sqrt(3.0);
  yrc = -M_SQRT2 * yrs;
  yrotate(hmat,yrs,yrc);

 /*
  * Shear the space to make the luminance plane horizontal...
  */

  xform(hmat, 0.3086, 0.6094, 0.0820, &lx, &ly, &lz);
  zsx = lx / lz;
  zsy = ly / lz;
  zshear(hmat, zsx, zsy);

 /*
  * Rotate the hue...
  */

  zrs = sin(rot * M_PI / 180.0);
  zrc = cos(rot * M_PI / 180.0);

  zrotate(hmat, zrs, zrc);

 /*
  * Unshear the space to put the luminance plane back...
  */

  zshear(hmat, -zsx, -zsy);

 /*
  * Rotate the grey vector back into place...
  */

  yrotate(hmat, -yrs, yrc);
  xrotate(hmat, -xrs, xrc);

 /*
  * Append it to the current matrix...
  */

  mult(hmat, mat, mat);
}