/*
* parentQuate:需要变换的对像
* angleX,angleY,angleZ: 旋转哪个方向
* angle:需要旋转的角度 0~360
*/
static public Quaternion ChangeRotation(GameObject parnetQuate, float angleX, float angleY, float angleZ, float angle,bool IsAnimation,float duration)
{
Quaternion ans = Quaternion.identity;
if( parnetQuate == null )return ans;
float norm;
float ccc, sss;
angle *= 3.14f / 180.0f;
ans.w = ans.x = ans.y = ans.z = 0.0f;
norm = angleX * angleX + angleY * angleY + angleZ * angleZ;
if(norm <= 0.0f)
{
if( IsAnimation)
TweenRotation.Begin(parnetQuate,duration,ans);
return ans;
}
norm = 1.0f / Mathf.Sqrt(norm);
angleX *= norm;
angleY *= norm;
angleZ *= norm;
ccc = Mathf.Cos(0.5f * angle);
sss = Mathf.Sin(0.5f * angle);
ans.w = ccc;
ans.x = sss * angleX;
ans.y = sss * angleY;
ans.z = sss * angleZ;
if( IsAnimation)
TweenRotation.Begin(parnetQuate,duration,ans);
return ans;
}