Since we are looking for a bounding rectangle, we need to calculate minX, maxX, minY, maxY.
Intuition: Just compare with the up-most, leftmost, rightmost and the down-most point of the circle!
Next, we have to determine whether a point on a circle is on an arc.
Arrange the two ends of the arc A,B such that A->B is clockwise.
To check whether P is on the arc, just see whether triangle APB is clockwise or not, which can be easily done by cross product.
Last Bug:
mnx = (int)(mnx+1e-10); mny = (int)(mny+1e-10); mxx = ceil(mxx-1e-10); mxy = ceil(mxy-1e-10);
Correct version:
mnx = floor(mnx+1e-10); mny = floor(mny+1e-10); mxx = ceil(mxx-1e-10); mxy = ceil(mxy-1e-10);
Incorrect version won't work with negative numbers..
No comments:
Post a Comment