tags:

views:

61

answers:

1

i need to check that a given point is present or not in the given region of a circle how can i do so is there any function in ansi c to help me?

+3  A: 

Do you want to check if point belongs to a circle or in some subregion in the circle?

To check if point belongs to the circle you can simply check if the distance from this point to the circle center is less then circle radius.

if ((point.x - center.x)*(point.x - center.x) + 
           (point.y - center.y)*(point.y - center.y) < radius*radius)
  // point is inside circle 
Vladimir
If the problem is specifically to find a function to help, the only reasonable candidate would be sqrt - the square root function. It's better to avoid that, though, and do what Vladimir has done.
Steve314