For each line we need to know its endpoints and its dual line. Their references (endPointA, endPointB and dualLine) make up the data of the object of type Line.

The endpoints of a line may not be defined, then they have the value null. The boolean function “undefined” detects this and returns true if an endpoint of a line or the position of an endpoint is undefined. Such lines are removed at the end of the program before showing a tiling.

We have also to be careful because we do not know the orientation of a line. If a point p is an endpoint of a line it might be either endPointA or endPointB. But a simple comparison such as (p==endPointA) resolves this problem. Note that this is fast because it compares only the references to these points and not their data. Thus the methods “setAnEndPoint”, “getOtherEndPoint” and “commonEndPoint” do not loose much time.

We use “getOtherEndPoint” to go along connecting lines from point to point in the tiling. “commonEndPoint” gives us a corner point of a polygon if we know two lines that meet there. If these methods have problems, they return null. The calling routine can check for this exception and prevent a break down of the program.

### Like this:

Like Loading...

*Related*