Lines and Polylines
The Straight Line
Definition
Line
CAD programs produce quick ways of drawing regular, well defined shapes like rectangles, triangles, etc. After all, they are
only connected multiple lines and the most efficient way of storing them is in the form of a polyline.
A line is generally taken to be a straight line between two points, it consists of
These two nodes (reference points) are used by the programmer to calculate information about the line itself.
For Example: from these two nodes, the programmer could calculate the length of the line and the angle of the line.
A line that has changes in direction may consist of, say, 3 separate lines OR may be one continuous line.

The 3 lines in the middle of the diagram only look continuous but are in fact 3 separate lines and will have the following information stored.
They are separate lines and are treated as separate lines.
Polyline
The polyline on the right of the diagram is made up of 3 segments that are continuous, and is generally known as a Polyline. This line has the following information.
The 3 lines making up the polyline are treated in every way as if they were one continuous line.
Example
If you wanted to write your own CAD program. As part of the enormous amount of work you would have ahead of you,
you would have to decide on the structure of the information your program would hold about the elements that go
to make up a drawing. Every CAD program has a structure for the data they hold. It always differs to a competitors product
and so we can never just open up, for example, an AutoCAD drawing in a MiniCAD program (unless they have special translator programs).
We will make up our own structure to hold the drawing details given below.
On a piece of paper draw a 99x99 unit BOX made up of separate straight lines. The structure of the data could be as follows
LINE coords 0 0 99 0
Notice that each line making up the square is stored as a separate object and must contain a complete description.
LINE coords 99 0 99 99
LINE coords 99 99 0 99
LINE coords 0 99 0 0
The same box could be drawn using a polyline.
POLYLINE coords 0 0 99 0 99 99 0 99 0 0
Notice that this description is much smaller.
So even though you may select an option to draw a hexagon, the six connected lines are stored as a single polyline sequence. When
you interrogate the CAD drawing database of information there are no references to hexagons or rectangles only lines and polylines!
A rectangle only needs a diagonally opposite corner to be specified to enable the program to work out the length and height.
