Wpf Math Boundary Logic
I need some enlightenment on what might be a simple question.
Given a circle of coordinates Xn and Yn that act as boundary and given the coordinate of a control's center at X1 and开发者_StackOverflow社区 Y1. How do I check if the control lies within the boundary?
I tried,
X2 & X3 = the left & right peak of the circle in term of X axis.
Y2 & Y3 = the top & bottom peak of the circle in term of Y axis.
If( X1 > X2 && X1 < X3 && Y1 > Y2 && Y1 < Y3)
return true;
However, this clearly doesn't work as the four corner of the circle will return true when it's not suppose to. Any ideas?
Can you use something like r = sqrt(xn*xn + yn*yn) to determine the radius of the circle? Even easier would be r = xn when yn = 0. Then you can calculate r1 = sqrt(x1*x1 + y1*y1) to find out if r1 < r. If it is, then it's inside the circle.
精彩评论