Standard Position and ArcShape

I mention this because I seem to often make errors when dealing with ArcShape.

There is a concept in trigonometry of “standard position” when discussing angles/arc.
When you speak of a 45° angle conventionally you are speaking of an arc that starts at 0° (pointing to the right on the positive x axis) and extends 45° counterclockwise from this start position. This arc “points”, as it were, up and to the right.

In Xojo, the ArcShape is defined in what I consider a “peculiar” way. You specify a StartAngle and an ArcAngle. The StartAngle is by default 0° [in Xojo these are expressed in radians so that is 0 radians]. That is in line with the “standard position” of trigonometry.

But if the ArcAngle is 45° (in radians Pi / 4) you will be specifying an arc that is clockwise from that zero position. This arc “points”, as it were, downward and to the right.

I don’t understand why Xojo adapted this convention of “clockwise” rotation when most of the trigonometry world adheres to a different one. But it is something to look out for.

The Documentation only explains things in Notes at the end where it is easily missed. It does not emphasize that its decision is “unconventional” in the context of trigonometry. It is in accord with how positive angles are considered with other Object2D entities.

The example for StartAngle offers:

Var a As New ArcShape
a.Height = 150
a.Width = 150
\\ a.Rotation = 0.90
a.ArcAngle = 1.57
a.StartAngle = -1.57
a.BorderOpacity = 100
a.BorderColor = Color.Black
a.BorderWidth = 2.75
a.FillOpacity = 50
a.FillColor = Color.Red
g.DrawObject(a)

The 1.57 is radians for 90°. Throw out the Rotation line that just works to confuse the example. This relates in a 90° arc oriented up and to the right. With the 90° negative start angle, this is not what I would have anticipated from the standard conventions of trigonometry.

I contribute this because I wasted a lot of time stumbling around with “unexpected” results. Perhaps I can save someone else this frustration. At the very least, the Documentation on this issue should be expanded.

I guess this is because the Y is upside down on the screen compared to a paper we use in the real world.

On the screen (a Xojo window for example) X, Y at 0, 0 is top left, and Y positive goes down. On a paper you can set 0, 0 at bottom left and Y positive goes up.

If you see the results of your code by ‘flipping’ the result vertically, then it match the paper.

Edit, some code trying to explain the behavior:

Var a As New ArcShape
a.Height = 150
a.Width = 150
a.x = 100
a.y = 100
//a.ArcAngle = 1.57 //will look clockwise
a.ArcAngle = -1.57 //will look "normal"
a.BorderOpacity = 100
a.BorderColor = Color.Black
a.BorderWidth = 2.75
a.FillOpacity = 50
a.FillColor = Color.Red
g.DrawObject(a)
1 Like