From 4f451da99badd42cf2df617353dcdadb2c2eec98 Mon Sep 17 00:00:00 2001 From: Star Brilliant Date: Mon, 28 Apr 2014 13:08:36 +0800 Subject: [PATCH] Pass rotation angles directly when rotY or rotZ equals to 0 or 180 degrees --- danmaku2ass.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/danmaku2ass.py b/danmaku2ass.py index fc03f3e..9c3a84a 100755 --- a/danmaku2ass.py +++ b/danmaku2ass.py @@ -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))