Pass rotation angles directly when rotY or rotZ equals to 0 or 180 degrees

This commit is contained in:
Star Brilliant 2014-04-28 13:08:36 +08:00
parent f95697edd8
commit 4f451da99b

View File

@ -538,11 +538,16 @@ def ConvertFlashRotation(rotY, rotZ, X, Y, FOV=math.tan(2*math.pi/9.0)):
return WrapAngle(theta)
X = 2*X-1
Y = 2*Y-1
rotY = -rotY*math.pi/180.0 # Positive value means clockwise in Flas
rotZ = -rotZ*math.pi/180.0
outY = math.atan2(-math.sin(rotY)*math.cos(rotZ), math.cos(rotY))*180/math.pi
outZ = math.atan2(-math.cos(rotY)*math.sin(rotZ), math.cos(rotZ))*180/math.pi
outX = math.asin(-math.sin(rotY)*math.sin(rotZ))*180/math.pi
if WrapAngle(rotY) in (0, 180) or WrapAngle(rotZ) in (0, 180):
outX = 0
outY = -rotY # Positive value means clockwise in Flash
outZ = -rotZ
else:
rotY = rotY*math.pi/180.0
rotZ = rotZ*math.pi/180.0
outY = math.atan2(-math.sin(rotY)*math.cos(rotZ), math.cos(rotY))*180/math.pi
outZ = math.atan2(-math.cos(rotY)*math.sin(rotZ), math.cos(rotZ))*180/math.pi
outX = math.asin(-math.sin(rotY)*math.sin(rotZ))*180/math.pi
outX = CalcPerspectiveCorrection(outX, -Y, FOV*0.75)
outY = CalcPerspectiveCorrection(outY, X, FOV)
return (round(outX), round(outY), round(outZ), 0, round(-0.75*Y*math.sin(outY*math.pi/180.0), 3))