mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-16 13:46:54 +00:00
Fix polyline tool calculation when dealing with 180 degrees angles.
This commit is contained in:
@@ -102,6 +102,10 @@ class Cad:
|
|||||||
d1 = v1 - v2
|
d1 = v1 - v2
|
||||||
d2 = v3 - v2
|
d2 = v3 - v2
|
||||||
|
|
||||||
|
# Rounding avoids problems when dealing with 180 degrees
|
||||||
|
d1 = Vector((round(c, 6) for c in d1))
|
||||||
|
d2 = Vector((round(c, 6) for c in d2))
|
||||||
|
|
||||||
d1.normalize()
|
d1.normalize()
|
||||||
d2.normalize()
|
d2.normalize()
|
||||||
|
|
||||||
@@ -123,12 +127,24 @@ class Cad:
|
|||||||
if new_angle is not None:
|
if new_angle is not None:
|
||||||
rot_mat = Matrix.Rotation(new_angle, 3, axis)
|
rot_mat = Matrix.Rotation(new_angle, 3, axis)
|
||||||
rot_vector = (d1 @ rot_mat) if parameter else (rot_mat @ d1)
|
rot_vector = (d1 @ rot_mat) if parameter else (rot_mat @ d1)
|
||||||
|
|
||||||
|
# 180 degrees special cases
|
||||||
|
if abs(round(a, 4)) == round(math.pi, 4) and (
|
||||||
|
rot_vector.x == 0.0 and rot_vector.y == 0.0 or
|
||||||
|
rot_vector.x == 0.0 and rot_vector.z == 0.0 or
|
||||||
|
rot_vector.y == 0.0 and rot_vector.z == 0.0
|
||||||
|
):
|
||||||
|
rot_vector *= -1
|
||||||
return rot_vector
|
return rot_vector
|
||||||
else:
|
else:
|
||||||
sign = -1 if parameter else 1
|
sign = -1 if parameter else 1
|
||||||
|
|
||||||
if degrees:
|
if degrees:
|
||||||
a = math.degrees(a)
|
a = math.degrees(a)
|
||||||
|
|
||||||
|
# 180 degrees special cases
|
||||||
|
if abs(round(a, 2)) == abs(180.00):
|
||||||
|
return -180.0
|
||||||
return a * sign
|
return a * sign
|
||||||
else:
|
else:
|
||||||
return a
|
return a
|
||||||
|
|||||||
Reference in New Issue
Block a user