class Line

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.

This entry was posted in programming and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s