In which quadrant is a point?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Timur Navruzov
am 4 Dez. 2015
Kommentiert: Timur Navruzov
am 4 Dez. 2015
Hi
I have a 'circle' with irregular perimeter. Somewhere within that circle is a point. The circle is divided into 4 quadrants by 2 lines 45 and 135 degrees to x- axis.I know the coordinates of the point. How can I find exactly in which quadrant it lies?
Thank you
0 Kommentare
Akzeptierte Antwort
Torsten
am 4 Dez. 2015
The four quadrants are characterized by the following conditions (if the center of the circle is at (0,0)):
I quadrant: y<=x, y>=-x
II quadrant: y>=x y>=-x
III quadrant: y<=x, y>=-x
IV quadrant: y<=x, y<=-x
Use an if-statement to determine which quadrant the point under consideration is in.
Best wishes
Torsten.
Weitere Antworten (1)
Thorsten
am 4 Dez. 2015
Bearbeitet: Thorsten
am 4 Dez. 2015
If cx, cy is the center of your circle, you first determine the angle between point px, py and relative to the center:
alpha = atan2(py-cy, px-cx);
Ensure that the angle is in the range [0,2*pi]:
if alpha < 0, alpha = alpha + 2*pi; end
The 45deg slice (== pi/4) that holds your point has the number
Oc = floor(alpha/(pi/4));
Numbers range from 0 to 7 counter-clockwise and start with the octant 0 to the right of the center.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Graphics Object Properties finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!