コード例 #1
0
ファイル: gl_camera.hpp プロジェクト: anirul/MOLA_parser
    void rotate(const vector<T> v) {
	const T maxz = (T)100;
	const T minz = (T)5;
	// X
	vector<T> pos = this->pos_ - target_;
	matrix<T> rot_y(
	    (T)cos(v.x), (T)0, (T)-sin(v.x),
	    (T)0, (T)1, (T)0,
	    (T)sin(v.x), (T)0, (T)cos(v.x));
	pos = pos * rot_y;
	pos = pos + target_;
	// Z
	vector<T> ta2po = this->pos_ - target_;
	ta2po = !ta2po * (ta2po.length() + v.z);
	if (ta2po.length() > maxz)
	    ta2po = !ta2po * maxz;
	if (ta2po.length() < minz)
	    ta2po = !ta2po * minz;
	// Y
	T t2pl = ta2po.length();
	ta2po.y += v.y;
	ta2po = !ta2po * t2pl;
	this->pos_ = ta2po + target_;
	// recompute up
	up_ = vector<T>((T)0, (T)1, (T)0);
	vector<T> right = up_ % (target_ - this->pos_);
	up_ = (target_ - this->pos_) % right;
	up_ = !up_;
    }
コード例 #2
0
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 );
    }
}
コード例 #3
0
ファイル: t_v3tools.cpp プロジェクト: korantu/vx2
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);


};
コード例 #4
0
ファイル: point_rotation.c プロジェクト: island-faz/rt00
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));
}
コード例 #5
0
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;
}
コード例 #6
0
ファイル: 3dtools.cpp プロジェクト: yangguang-ecnu/voxelbrain
 /// 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);
 };
コード例 #7
0
ファイル: rotation.c プロジェクト: TetraSomia/Ray-Tracer
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);
}
コード例 #8
0
ファイル: rotation.c プロジェクト: TetraSomia/Ray-Tracer
void	rot_vec(t_vec *vec, t_vec *angle)
{
  rot_x(vec, angle->x);
  rot_y(vec, angle->y);
  rot_z(vec, angle->z);
}