Jump to content


Circle for checking boundary conditions


2 replies to this topic

#1 udvat

    Valued Member

  • Members
  • PipPipPip
  • 108 posts

Posted 18 June 2007 - 04:37 AM

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.

#2 Reedbeta

    DevMaster Staff

  • Administrators
  • 4782 posts
  • LocationBellevue, WA

Posted 18 June 2007 - 04:45 AM

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.
reedbeta.com - developer blog, OpenGL demos, and other projects

#3 geon

    Senior Member

  • Members
  • PipPipPipPip
  • 812 posts

Posted 18 June 2007 - 01:24 PM

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.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users