Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
You write down the function by which the lines are built, between which it is necessary to check whether the point lies.
You substitute X points into a function, you calculate Y for this function.
Compare with Y points. If they are equal, the point lies on the line; if not, it lies above or below, respectively.
And you just set the necessary conditions for checking how the point should lie, above or below the given lines.
And what about C#? This is a common math problem. If X<0, then Y must lie under the line, otherwise above the line.
You can use some library, you can dream up with Rectangle.Contains.
Circle:
(x - x0)^2+(y-y0)^2 < R^2 - set of points inside the circle
(x - x0)^2+(y-y0)^2 > R^2 - set of points outside the circle
R - radius of the circle, x0, y0 - coordinates of the center
Ellipse:
((x - x0)/a)^2+((y-y0)/b)^2 < 1 - set of points inside the ellipse
((x - x0)/ a)^2+((y-y0)/b)^2 > 1 - set of points outside the ellipse
a, b - radii of the ellipse
Straight lines:
x < 0 - set of points to the left of the axis 0Y
x > 0 - set of points to the right of the axis 0Y
y < 0 - set of points below the 0X axis
y > 0 - set of points above the 0X axis
ax+by < c set of points below the line given by the equation ax+by = с
ax+by > c set of points above the line given by the equation ax+by = c
For your task:
1. Find the right coefficients for all lines and curves.
2. Find out for each equation the sign that is obtained when a point hits in the shaded area
3. Create a set of tests for a point.
For example, for zone B:
The point must be inside the circle, outside the ellipse and above the straight line, that is, the following inequalities must be satisfied (the coefficients a, b x0, y0 are different for each inequality):
(x - x0)^2+(y-y0) ^2 < R^2 ((x - x0)/a)^2+((y-
y0
)/b)^2 > 1
ax+by > c
belongs to the shaded area.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question