Calculating the Bounding Rectangle of a Circular Sector
asawicki.info
asawicki.info
I don't remember exactly what I was doing but I think you might also be able to skip the for loop by directly calculating the point on the axis by using mod or floor/ceil.