Introduction to Computer Graphics
Lecture 2
2-D Primitives
Don Herbison-Evans
donherbisonevans@yahoo.com
(updated 23 August 2006)
2D Entities
Interconversions
The finite part of the infinite line is specified using the parameter 't' :
Drawing a line on a raster display
Pitfalls overcome by Bresenham's algorithm:
Get other octants by combination of
There is still the problem of intensity being dependent on direction
Inclusion of a point in a polygon
Clipping one polygon by another polygon
Two nested loops are needed, one stepping throught the edges of one polygon, the other loop stepping through the edges of the other polygon, so that every edge of one polygon is intersected with every edge of the other polygon.
If any intersection is within the segment length of both edges, then a new vertex must be added to the vertices of the output polygon.
There is a choice of whether the output polygon is initialised to the polygon of the inner or the outer loop.
The complication is that the edges and vertices of output polygon change as the clipping proceeds.
There are various simplifications can be made if one polygon is a rectangular viewing window. The algorithms for this have the rectangular window as the inside loop, and the output polygon initialised to the outer loop polygon:
Filling a polygon
Note:
if the boundary is marked using queens moves, the the flood must be done with rooks moves.