Cycle::winding
makes assumptions that don't hold for all cycles
#2130
Labels
topic: core
Issues relating to core geometry, operations, algorithms
type: bug
Something isn't working
Cycle::winding
is a method that computes the winding of a cycle (as the name suggests), meaning it determines whether a cycle's half-edges are oriented clockwise or counter-clockwise. The method works well for all cycles made up of straight half-edges (i.e. polygons) and circles. It does not work for all cycles that contain arcs, as it makes some assumptions that don't always hold in the presence of those.Exhibit A:
fornjot/crates/fj-core/src/objects/kinds/cycle.rs
Lines 46 to 51 in 3e3e992
Imagine a half-circle whose end-points are connected by a line segment. Totally valid, but unless the arc happens to be the first half-edge in the cycle, it will trigger this panic.
Exhibit B:
fornjot/crates/fj-core/src/objects/kinds/cycle.rs
Lines 61 to 80 in 3e3e992
The comment is wrong! Imagine a crescent shape. This code treat that like two coincident line segments, meaning
sum
will be zero and we'll run into the panic.There might be more issues, but those are two that I happened to discover. I believe this once worked as designed, when we were limited to line segments and full circles. Once arcs were introduced, the assumptions here no longer held.
I think it makes sense to hold off on fixing this. Nobody has complained about this so far, and if #2118 works out, fixing it will become trivial.
The text was updated successfully, but these errors were encountered: