Пример #1
0
transf PositionStateEllipsoid::getCoreTran() const
{
	double a = getParameter("a");
	double b = getParameter("b");
	double c = getParameter("c");
	double beta = readVariable("beta");
	double gamma = readVariable("gamma");
	double tau = readVariable("tau");
	double distance = readVariable("dist");
	double px,py,pz;
	px =  a * cos(beta) * cos(gamma);
	py =  b * cos(beta) * sin(gamma);
	pz =  c * sin(beta);
	
	//compute normal direction - for some reason this always points INSIDE the ellipsoid
	vec3 n1(  -a*sin(beta)*cos(gamma), -b*sin(beta)*sin(gamma), c*cos(beta) );
	vec3 n2(  -a*cos(beta)*sin(gamma),  b*cos(beta)*cos(gamma), 0 );
	vec3 normal = normalise(n1) * normalise(n2);

	vec3 xdir(1,0,0);
	vec3 ydir = normal * normalise(xdir);
	xdir = ydir * normal;
	mat3 r(xdir,ydir,normal);

	transf handTran = transf(r, vec3(px,py,pz) - distance * normal);
	Quaternion zrot(tau, vec3(0,0,1));
	handTran = transf(zrot, vec3(0,0,0) ) * handTran;
	return mHand->getApproachTran().inverse() * handTran;
	//So: hand tranform is: move onto the ellipsoid and rotate z axis in normal direction
	//	  --> hand approach transform inverted to get to hand origin
}
Пример #2
0
void EpsWriter::setRotationMatrix ( aol::FullMatrix<double> &rot, double xang_deg, double yang_deg, double zang_deg ) {
  // rot is set to the rotation matrix specified by the three angles (in degrees)
  aol::FullMatrix<double> xrot ( 3, 3 ), yrot ( 3, 3 ), zrot ( 3, 3 );

  const double
    xang = xang_deg * 0.0174329252, // pi / 180
    yang = yang_deg * 0.0174329252,
    zang = zang_deg * 0.0174329252;

  xrot.set ( 0, 0,        1.0 );   xrot.set ( 0, 1,        0.0 );   xrot.set ( 0, 2,        0.0 );
  xrot.set ( 1, 0,        0.0 );   xrot.set ( 1, 1,  cos ( xang ) );   xrot.set ( 1, 2, -sin ( xang ) );
  xrot.set ( 2, 0,        0.0 );   xrot.set ( 2, 1,  sin ( xang ) );   xrot.set ( 2, 2,  cos ( xang ) );

  yrot.set ( 0, 0,  cos ( yang ) );   yrot.set ( 0, 1,        0.0 );   yrot.set ( 0, 2, -sin ( yang ) );
  yrot.set ( 1, 0,        0.0 );   yrot.set ( 1, 1,        1.0 );   yrot.set ( 1, 2,        0.0 );
  yrot.set ( 2, 0,  sin ( yang ) );   yrot.set ( 2, 1,        0.0 );   yrot.set ( 2, 2,  cos ( yang ) );

  zrot.set ( 0, 0,  cos ( zang ) );   zrot.set ( 0, 1, -sin ( zang ) );   zrot.set ( 0, 2,        0.0 );
  zrot.set ( 1, 0,  sin ( zang ) );   zrot.set ( 1, 1,  cos ( zang ) );   zrot.set ( 1, 2,        0.0 );
  zrot.set ( 2, 0,        0.0 );   zrot.set ( 2, 1,        0.0 );   zrot.set ( 2, 2,        1.0 );

  cerr << "Please ignore the following warnings. The matrices are only 3x3 ... " << endl;
  rot  = xrot;
  rot *= yrot;
  rot *= zrot;
  cerr << "Thank you for your patience :-)" << endl;
}
Пример #3
0
    void Camera::rotateCameraViewRelative(FLOAT x, FLOAT y, FLOAT z)
    {
        D3DXVECTOR3 dir(0,0,1);
        D3DXVECTOR3 up(0,1,0);
        D3DXVECTOR3 right;


        

        D3DXVec3Cross(&right, &up, &dir);

        D3DXQUATERNION xrot(right.x*sin(x*0.5f),right.y*sin(x*0.5f), right.z*sin(x*0.5f), cos(x*0.5f));
        D3DXQUATERNION yrot(up.x*sin(y*0.5f),up.y*sin(y*0.5f), up.z*sin(y*0.5f), cos(y*0.5f));
        D3DXQUATERNION zrot(dir.x*sin(z*0.5f),dir.y*sin(z*0.5f), dir.z*sin(z*0.5f), cos(z*0.5f));

        m_orientation =  yrot * m_orientation * xrot * zrot;
        m_viewCacheValid = false;
    }
Пример #4
0
Файл: p.c Проект: DavidToca/acm
static int get()
{
	static int a[6];
	int i, r, t, x, y, z;

	for (i = 0; i < 6; i++) {
		READ(t);
		a[i] = t - 1;
	}

	for (r = 0x3FFFFFFF, x = 0; x < 4; x++, xrot(a)) {
		for (y = 0; y < 4; y++, yrot(a)) {
			for (z = 0; z < 4; z++, zrot(a)) {
				for (t = 0, i = 0; i < 6; i++)
					t = t * 6 + a[i];
				if (t < r) r = t;
			}
		}
	}

	return r;
}
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
	vec2 uv = fragCoord.xy / iResolution.xy;
    uv = uv * 2.0 - 1.0;
    uv.x *= iResolution.x / iResolution.y;
    vec3 r = normalize(vec3(uv, 1.0 - dot(uv,uv) * 0.33));
    vec3 o = vec3(0.5, 0.5, time);
    o.xy -= vec2(sin(o.z), cos(o.z)) * 0.25;
    vec3 ts = times(0.213);
    r *= xrot(ts.y+ts.z) * yrot(ts.x+ts.z) * zrot(ts.x+ts.y);
    float t = trace(o, r);
    vec3 w = o + r * t;
    vec3 sn = normal(w);
    float fd = map(w);
    float prod = clamp(dot(r, -sn), 0.0, 1.0);
    vec3 colfar = vec3(1.0, 0.0, 0.0);
    vec3 colnear = vec3(1.0, 1.0, 1.0);
    float colk = 1.0 / (1.0 + t * t * 0.1);
    vec3 col = mix(colfar, colnear, colk);
    col *= texture(w * 0.1) * colk;
    float aoc = 1.0 / (1.0 + fd * 100.0);
    vec3 fc = sqrt(col) * aoc * prod;
	fragColor = vec4(fc,1.0);
}