        Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007

## UML Line Algorithms

Tim Shaw
Line Algorithms

Problem with Line(Arrow) Crossing
During the creating of UML Class diagram. The user might create the classes that connect to each other with arrows that cross with one another. This will be harder for the viewer to see what's actually going on in the Diagram. (See Figure 1.0)

Figure 1.0 Approaching the line Crossing problem
One way of resolving it is to create an alorithm that will search through all the line and see whether there is a point of intersection between the lines and if there's an intersection then the two classes that is causing the crossing will switch with each other.

Figure 1.1 Solving
The question now is how do you find whether two lines are crossing or not
To solve this let's label the four points of the two lines respectively the equations for the line
Pa = P1 + ua ( P2 - P1 )
Pb = P3 + ub ( P4 - P3 )
and the ua and ub's is found by plugging the x and y courdinates of P1 P2 P3 P4 into the following equation One characteristic of this equation is if the line segment is crossing then ua and ub will be in between the values of 0 and 1

Therefore just implement the switching of the classes when ua and ub are crossing will resolve a simple line crossing