Align arcs with new object model (#396)
This commit is contained in:
@@ -18,18 +18,19 @@ module SpeckleConnector3
|
||||
plane = arc['plane']
|
||||
units = arc['units']
|
||||
origin = Point.to_native(plane['origin']['x'], plane['origin']['y'], plane['origin']['z'], units)
|
||||
start_point = Point.to_native(arc['startPoint']['x'], arc['startPoint']['y'], arc['startPoint']['z'], units)
|
||||
end_point = Point.to_native(arc['endPoint']['x'], arc['endPoint']['y'], arc['endPoint']['z'], units)
|
||||
normal = Vector.to_native(plane['normal']['x'], plane['normal']['y'], plane['normal']['z'], units)
|
||||
x_axis = Vector.to_native(plane['xdir']['x'], plane['xdir']['y'], plane['xdir']['z'], units)
|
||||
radius = Geometry.length_to_native(arc['radius'], units)
|
||||
start_angle = arc['startAngle']
|
||||
end_angle = arc['endAngle']
|
||||
|
||||
# Normalize angles to range 0 to 2π
|
||||
start_angle %= 2 * Math::PI
|
||||
end_angle %= 2 * Math::PI
|
||||
start_vector = Vector.to_native(start_point.x - origin.x, start_point.y - origin.y, start_point.z - origin.z, units)
|
||||
end_vector = Vector.to_native(end_point.x - origin.x, end_point.y - origin.y, end_point.z - origin.z, units)
|
||||
|
||||
# Ensure start angle is less than end angle for proper drawing
|
||||
if start_angle > end_angle
|
||||
start_angle = Math.atan2(start_vector.cross(normal).dot(x_axis), start_vector.dot(x_axis))
|
||||
end_angle = Math.atan2(end_vector.cross(normal).dot(x_axis), end_vector.dot(x_axis))
|
||||
|
||||
if end_angle < start_angle
|
||||
end_angle += 2 * Math::PI
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user