ZeroDivisionError handling in ConvertFlashRotation
This commit is contained in:
parent
7b185020c7
commit
2fe749bb23
@ -532,10 +532,14 @@ def ConvertFlashRotation(rotY, rotZ, X, Y, width, height):
|
|||||||
trY = Y*math.cos(rotZ)-X*math.sin(rotZ)+math.sin(rotZ)*width/2+(1-math.cos(rotZ))*height/2
|
trY = Y*math.cos(rotZ)-X*math.sin(rotZ)+math.sin(rotZ)*width/2+(1-math.cos(rotZ))*height/2
|
||||||
trZ = (trX-width/2)*math.sin(rotY)
|
trZ = (trX-width/2)*math.sin(rotY)
|
||||||
FOV = width*math.tan(2*math.pi/9.0)/2
|
FOV = width*math.tan(2*math.pi/9.0)/2
|
||||||
|
try
|
||||||
scaleXY = FOV/(FOV+trZ)
|
scaleXY = FOV/(FOV+trZ)
|
||||||
if scaleXY < 0:
|
except ZeroDivisionError:
|
||||||
|
logging.error('Rotation makes object behind the camera: trZ == %.0f' % trZ);
|
||||||
scaleXY = 1
|
scaleXY = 1
|
||||||
logging.error('Clipped rotation: trZ == %.0f < %.0f' % (trZ, FOV));
|
if scaleXY < 0:
|
||||||
|
scaleXY = -scaleXY
|
||||||
|
logging.error('Rotation makes object behind the camera: trZ == %.0f < %.0f' % (trZ, FOV));
|
||||||
trX = (trX-width/2)*scaleXY+width/2
|
trX = (trX-width/2)*scaleXY+width/2
|
||||||
trY = (trY-height/2)*scaleXY+height/2
|
trY = (trY-height/2)*scaleXY+height/2
|
||||||
return (round(trX), round(trY), WrapAngle(round(outX)), WrapAngle(round(outY)), WrapAngle(round(outZ)), round(scaleXY*100), round(scaleXY*100))
|
return (round(trX), round(trY), WrapAngle(round(outX)), WrapAngle(round(outY)), WrapAngle(round(outZ)), round(scaleXY*100), round(scaleXY*100))
|
||||||
|
Loading…
Reference in New Issue
Block a user