Arc: Handle round-off issue with acos()
math.acos raises outside of valid range [-1, 1]. Handle round-off errors gracefully by using `round()` here too.pull/31/head
parent
316dc8bfe9
commit
ec63d0c312
|
@ -1300,10 +1300,13 @@ class Arc(object):
|
||||||
# delta is the angular distance of the arc (w.r.t the circle)
|
# delta is the angular distance of the arc (w.r.t the circle)
|
||||||
# theta is the angle between the positive x'-axis and the start point
|
# theta is the angle between the positive x'-axis and the start point
|
||||||
# on the circle
|
# on the circle
|
||||||
|
u1_real_rounded = u1.real
|
||||||
|
if u1.real > 1 or u1.real < -1:
|
||||||
|
u1_real_rounded = round(u1.real)
|
||||||
if u1.imag > 0:
|
if u1.imag > 0:
|
||||||
self.theta = degrees(acos(u1.real))
|
self.theta = degrees(acos(u1_real_rounded))
|
||||||
elif u1.imag < 0:
|
elif u1.imag < 0:
|
||||||
self.theta = -degrees(acos(u1.real))
|
self.theta = -degrees(acos(u1_real_rounded))
|
||||||
else:
|
else:
|
||||||
if u1.real > 0: # start is on pos u_x axis
|
if u1.real > 0: # start is on pos u_x axis
|
||||||
self.theta = 0
|
self.theta = 0
|
||||||
|
|
Loading…
Reference in New Issue