PDA

View Full Version : Circle for checking boundary conditions


udvat
06-17-2007, 09:37 PM
lets say,
my desired output image is composed of 400 pixels
I have stored all necessary informations of these pixels in an array[20][20].

Now I want to setup a circular boundary. If a pixel fall in the boundary,it should be drawn and otherwise not. How can I set and check this condition?
I want the center of the circle located at array[height/2][width/2] position.

Reedbeta
06-17-2007, 09:45 PM
Take the vector from the circle center to the pixel, find its length, and compare that to the radius of the circle. If it's smaller, the point is inside the circle.

geon
06-18-2007, 06:24 AM
Or use another channel as a mask to decide per-pixel wether to draw or not. The circle would then be precomputed, or loaded from a file.