Esempio n. 1
0
// V 经过 R 变换后为 V', 函数返回 V'
// 要求 R 先归一化
PNT  Ti_Rotation::VectorTransform(const PNT& V)const
{
	Ti_Rotation R = *this;
	if( (R.m_Angle>-DELTA_ROT) && (R.m_Angle<DELTA_ROT) ) 
		return V;
	R.m_Axis.Normalize();
	QUATERNION Q = RotationToQuaternion(R);
	Q.QuaternionNormalize();
	return Q.VectorTransform(V);
}
Esempio n. 2
0
Ti_Rotation  Ti_Rotation::operator * (const  Ti_Rotation& R2)const
{
     Ti_Rotation R1 = *this;
       if( (R1.m_Angle>-DELTA_ROT) && (R1.m_Angle<DELTA_ROT) )
	{
		return R2;
	}
	else if( (R2.m_Angle>-DELTA_ROT) && (R2.m_Angle<DELTA_ROT) )
	{
		return R1;
	}
	
	// 原始角度不为 0
	Ti_Rotation   R; 
	QUATERNION Q1= RotationToQuaternion(R1);
	QUATERNION Q2 =RotationToQuaternion(R2);
	QUATERNION Q = Q1*Q2; // 注意顺序
	R=Q.QuaternionToRotation();
	return R;
}
Esempio n. 3
0
void TransformComponent::Rotate(Vector3f v, float angle)
{
	Quaternion rq = RotationToQuaternion(v, angle);
	rotation = UnitQuatProduct(rotation, rq);
}