void ArcBall::setView( int view )
{
    m_zoom = 1.0;
    m_moveX = 0;
    m_moveY = 0;
    m_oldMoveX = 0;
    m_oldMoveY = 0;
    m_currentRot.setToIdentity();
    m_lastRot.setToIdentity();

    QQuaternion rotx( sqrt(0.5), 0, 0, sqrt(0.5) );
    QQuaternion rot_x( -sqrt(0.5), 0, 0, sqrt(0.5) );
    QQuaternion roty( 0, sqrt(0.5), 0, sqrt(0.5) );
    QQuaternion rot_y( 0, -sqrt(0.5), 0, sqrt(0.5) );
    QQuaternion rotz( 0, 0, sqrt(0.5), sqrt(0.5) );

    if ( view == 2 )
    {
        m_currentRot.rotate( rotz );
        m_currentRot.rotate( rotx );
        m_currentRot.rotate( rotx );
    }
    if ( view == 3 )
    {
        m_currentRot.rotate( rot_x );
        m_currentRot.rotate( rot_y );
    }
}
Beispiel #2
0
int main(){
  V3f x(0,0,1); V3f xr(rot_x(x, 0.87)); same("x rotation", x.dot(xr), cos(0.87));
  V3f y(0,0,1); V3f yr(rot_y(y, 0.23)); same("y rotation", y.dot(yr), cos(0.23));
  V3f z(1,0,0); V3f zr(rot_z(z, 0.19)); same("z rotation", z.dot(zr), cos(0.19));

  V3f nx(3,2,5);
  V3f ny(-2,3,4);
  V3f nz(-4,4,3.8);

  V3f nnx(3,2,5);
  V3f nny(-2,3,4);
  V3f nnz(-4,4,3.8);

  ortoNormalize(nnx, nny, nnz);
  
  same("x unit", nnx.length(), 1.0);
  same("y unit", nny.length(), 1.0);
  same("z unit", nnz.length(), 1.0);

  V3f tmp; tmp.cross(nnx, nx);

  same("x colinear", tmp.length(), 0.0);
  
  tmp.cross(nnx, nny); tmp-=nnz; same("x orto", tmp.length(), 0);
  tmp.cross(nny, nnz); tmp-=nnx; same("y orto", tmp.length(), 0);
  tmp.cross(nnz, nnx); tmp-=nny; same("z orto", tmp.length(), 0);


};
Beispiel #3
0
void		rotate(t_dpoint *coor, double angle_x,
		       double angle_y, double angle_z)
{
  if (angle_x != 0.0)
    rot_x(coor, cos(angle_x), sin(angle_x));
  if (angle_y != 0.0)
    rot_y(coor, cos(angle_y), sin(angle_y));
  if (angle_z != 0.0)
    rot_z(coor, cos(angle_z), sin(angle_z));
}
Beispiel #4
0
Attitude::Attitude(const float dipAngle, const float dip, const Vector3f position)
{

    if ((dipAngle <= 0.0) | (dipAngle >= 90))
        LOG(WARNING) << "dipAngle out of bounds. Are you sure" << std::endl;

    Vector3f n = Vector3f::UnitZ(); // is a vertical vector
    // we rotate a vertical vector on the two axis, of the given angles
    AngleAxis<float> rot_x(dipAngle / 180 * M_PI, -Vector3f::UnitX());
    AngleAxis<float> rot_z(dip / 180 * M_PI, -Vector3f::UnitZ());

    Vector3f out_n = rot_z * rot_x * n;

    this->setNormal(out_n.normalized());
    this->setPosition(position);
}
glm::mat4 CreateRotateMatrix(float rx, float ry, float rz) {
	glm::mat4 rot_x(1.0f);
	rot_x[1][1] = cos(rx);
	rot_x[2][1] = -sin(rx);
	rot_x[1][2] = sin(rx);
	rot_x[2][2] = cos(rx);

	glm::mat4 rot_y(1.0f);
	rot_y[0][0] = cos(ry);
	rot_y[2][0] = sin(ry);
	rot_y[0][2] = -sin(ry);
	rot_y[2][2] = cos(ry);

	glm::mat4 rot_z(1.0f);
	rot_z[0][0] = cos(rz);
	rot_z[1][0] = -sin(rz);
	rot_z[0][1] = sin(rz);
	rot_z[1][1] = cos(rz);

	return rot_z * rot_y * rot_x;
}
Beispiel #6
0
 /// first argument - rotation over x axis;
 /// second - over y axis
 /// which means they are inverted for mouse navigation.
 void Rotate(float x, float y){
   ex = rot_x(ex,x); ey = rot_x(ey,x); ez = rot_x(ez,x);
   ex = rot_y(ex,y); ey = rot_y(ey,y); ez = rot_y(ez,y);
   //printf("%f\n",ex.x);;
   ortoNormalize(ex,ey,ez);
 };
Beispiel #7
0
void	rot_vec_inv(t_vec *vec, t_vec *angle)
{
  rot_x(vec, -angle->x);
  rot_y(vec, -angle->y);
  rot_z(vec, -angle->z);
}
Beispiel #8
0
void	rot_vec(t_vec *vec, t_vec *angle)
{
  rot_x(vec, angle->x);
  rot_y(vec, angle->y);
  rot_z(vec, angle->z);
}