CSC 418/2504 Fall 2001: Code for A2 Q4
For this question, the brute-force approach will be enough.
You can implement efficient anti-aliasing software, but
you don't have to.
- For pre-filtering, you will have to clip the polygon against
each of the pixels. I wrote some code to check question 3 of
assignment 1, which clips a polygon against a rectangle:
- clip.cpp : code
- clip.bat : batch file for MS-DOS
- test.dat : input file. Note that the
program doesn't handle vertical clipping lines with x=0
correctly, so I nudged it a bit.
- For supersampling, replace each point in the middle of a pixel
with four points, and count how many of the four fall inside the
polygon.
Code to test if a point is inside a polygon is available
from last year's assignments:
point-in-polygon.c
Alejo Hausner,
Dept of Computer Science,
University of Toronto
Last modified: Tue Nov 20 17:08:21 EST 2001