diff --git a/node-graph/gcore/src/vector/misc.rs b/node-graph/gcore/src/vector/misc.rs index 291fc72c21..837eba3db1 100644 --- a/node-graph/gcore/src/vector/misc.rs +++ b/node-graph/gcore/src/vector/misc.rs @@ -189,7 +189,10 @@ pub fn bezpath_to_manipulator_groups(bezpath: &BezPath) -> (Vec PI - min_angle_threshold.to_radians() { - new_manipulator_groups.push(manipulator_groups[curr_idx]); + if cos - cos_threshold > EPSILON { + new_manipulator_groups.push(*current_group); continue; } + // Calculate sine of half the angle using trig identity + let sin = (1. - cos * cos * 0.25).sqrt(); + // Calculate L, with limits to avoid extreme values - let distance_along_edge = radius / (theta / 2.).sin(); - let distance_along_edge = distance_along_edge.min(edge_length_limit * (curr - prev).length().min((next - curr).length())).max(0.01); + let distance_along_edge = radius / sin; + let distance_along_edge = distance_along_edge.min(edge_length_limit * curr.distance(prev).min(curr.distance(next))).max(0.01); // Find points on each edge at distance L from corner let p1 = curr - dir1 * distance_along_edge;