Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#547] Fix Connection Point of Edges and Nodes in State Diagrams #548

Merged

Conversation

jkcoding7
Copy link

@jkcoding7 jkcoding7 commented May 15, 2024

Issue

Edges in state diagrams connecting to the corner SW and SE points of rounded rectangles are positioned incorrectly. This can happen at either endpoints of the edge, as shown below.
image

Location of Error

The error was in GeomUtils#intersectRectangle, which is called by GeomUtils#intersectRoundedRectangle to calculate the precise connection point on the rounded portions of the rounded rectangle.

What was Wrong

The problem occurs when the edge is positioned on the exact corner point in the SW and SE direction.
The if conditions in intersectRectangle uses the ifBetween(start, end) method to check whether a direction is between start and end. The start and end value themselves are exclusive. For instance, 60° would not be between 60° (start) and 90° (end). (The documentation, which says that the starting direction is inclusive, may have been the reason for the oversight which led to this miscalculation).

So, by the logic of the if/else-if/else branch in intersectRectangle, if a user positions two nodes such that the edge is pointing in the exact direction of diagonalSE, the flow of execution would be delegated to the else branch, despite the fact that it should be handled by one of the appropriate if/else if branch, which in this case could be else if( pDirection.isBetween(diagonalNE, diagonalSE) ). Interestingly, this did not impact the NW and NE corners because these two cases can be handled appropriately by the else branch in any case.

Fix

By incrementing the range of the end values by 1 to include corner directions, we can ensure that the calculation is handled by the correct branch of if statements, and thus compute the offset for the connection points between node and edge correctly. To continue the example above, to fix the connection point for the SE corner, we can include the SE corner direction with the following code: else if( pDirection.isBetween(diagonalNE, diagonalSE.rotatedBy(1)) )

@prmr prmr merged commit 7f98abc into prmr:Integration_3_8 May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants