-
Notifications
You must be signed in to change notification settings - Fork 3
Description
Arcs behave a bit weirdly, snapping to wrong positions and such sometimes.
The relevant code is setPerpDistance() in arc_segment_state.py.
This function is called to set a new arc curvature through perpDistance: the distance in inches from the arc midpoint to the midpoint between the two nodes. That's what the user changes. However, this number may be modified if the start and end angles are close enough to be snapped to something like a different segment, in which perpDistance must be recalculated to determine the correct curvature to snap.
I will explain step-by-step the current function contents.
startTheta, endTheta = self._getThetasFromPerpDistance(perpDistance)
This function finds the theta at the endpoints of the arc given the original perpDistance (derived from mouse dragging.) This should work
newStartTheta = self.model.getConstrainedStartTheta(startTheta) newEndTheta = self.model.getConstrainedEndTheta(endTheta)
These functions identify any constraints and snap to them if any. If there is no snapping, those functions return None. This also works.
if newStartTheta is not None: perpDistance = self._getPerpDistanceFromTheta(newStartTheta, perpDistance, isStartTheta = True) elif newEndTheta is not None: perpDistance = self._getPerpDistanceFromTheta(newEndTheta, perpDistance, isStartTheta = False)
This is where things get dicey. From the snapped thetas, the new perpdistance needs to be determined. This is likely where the problem is.
It seems like problems arise in relation to the parity of the arc - which side of the circle it is given two angles, whether it's positive or negative, etc. So the core math is fine but these sign flips and things are what's causing issues.
The rest of the code just makes sure the curvature isn't too low, updates the model, and calls any update callbacks.
Metadata
Metadata
Assignees
Labels
Projects
Status