wxWidgets / Phoenix

wxPython's Project Phoenix. A new implementation of wxPython, better, stronger, faster than he was before.
http://wxpython.org/
2.3k stars 515 forks source link

DC.DrawEllipticArc documentation needs clarification #1830

Open kdschlosser opened 3 years ago

kdschlosser commented 3 years ago

Operating system: Windows 7 x64 wxPython version & source: pypi 4.1.0 Python version & source: 3.7 CPython Description of the problem: so the wording in the docs is this.

start and end specify the end points of the arc relative to the three-o’clock position from the center of the rectangle. Angles are specified in degrees with 0 degree angle corresponding to the positive horizontal axis (3 o’clock) direction.

so lets draw a rectangle. x=50 y=50 w=100 h=100 the corners of the rectangle would be

top left: 50, 50 top right: 150, 50 bottom right: 150, 150 bottom left: 50, 150

the center of that rectangle is 100, 100

so if we turn 100, 100 into 0, 0 using the wx coordinate system you get this for the corners of the rectangle top left: -50, -50 top right: 50, -50 bottom right: +50, +50 bottom left: -50, +50

this makes x to the right of 0, 0 a positive number and y to the bottom of 0, 0 a positive number.

so wx coordinate system is a left handed Cartesian coordinate system where positive x is to the right and positive y is down. This would be a clockwise angle rotation.

in the image below the left side is left handed and the right is right handed, the x and the y in the picture are positive. so if + y is up and + x is to the right then you have a right handed Cartesian coordinate system in which the rotation is counter clockwise as depicted with the red rotation arrow. image

and then to make it even more mind boggling this is in the docs for the method

Independently of whether start is greater than or less than end, the arc is drawn in the counter-clockwise direction. Also, if start is equal to end, a complete ellipse is drawn.

what does this mean???

if I pass a start angle of 180 and a stop angle of 90 what should I get? I should get this image

but what I get is this. image which is 180 start and 450 stop

This does not make any sense.. First off the rotation is always counter-clockwise which is backwards for the coordinate system that wx uses. and the method is altering the angles that I have provided

this is what the method is doing to the angles.

while start >= stop:
    stop += 360

if passing 0 as the start and -90 as the stop should be the same as passing 270 as the start and 360 as the stop but it is not.

So in summary. This method uses a coordinate system that I have not been able to locate any information on. It seems to be part left handed Cartesian and part right handed Cartesian. the direction of rendering is always counter clockwise but if the start angle is higher then the stop the method does not simply flip flop the 2. it changes the values.

The documents should read "The direction the arc is rendered is always counter clockwise. If the start angle is greater than or equal to the stop angle the stop angle will have 360 added to it until the stop angle is greater than the start angle."

I believe that is easier to grasp what is happening.

RobinD42 commented 3 years ago

That text is coming from the wxWidgets documentation so you'll want to open a ticket or file a PR there for this change.