Find ArcAngle and StartAngle

Me: Daniel Lamet, old hacker, running a 2020 M1 Mac Mini, running MacOS Sequoia 15.1.1
with XOJO 2024, release 4

Xojo defines several shape classes: RectShape, OvalShape, etc. My desktop app draws various of these defined shapes based on what a user drags in the window. For a rectangle, the app catches the mouse down event and lets the user drag until the mouse up event and then creates the rectangle defined by those two corners.

For an arc shape, the user presses, at P1, the mouse button to draw a line until the mouse up, at P2, which then defines the line between two points P1 and P2. Then the user presses the mouse button again at P2 and drags a line to P3. So I want to create the arc between the lines P1P2 and P2P3 with the vertex P2.

I would greatly appreciate help calculating the ArcAngle and the StartAngle for this ArcShape.

I have made some progress. I think that the Law of Cosines is reliably calculating the ArcAngle.

But I have not made much progress finding the StartAngle. Part of the problem is realizing that the StartAngle is the angle between the positive x-axis and a side of the arc, with positive angles being clockwise rotations around a pivot. Is this even correct?

As far as I remember the angle and positive/negative is totally foobared in Xojo. I had some example code and a picture to remind me how this works. You should find some example code here in the forum or in my TrixisTabsheets from Xojo + Alfred .

1 Like

maybe better use the FigureShape

Var f As New FigureShape
f.AddQuad 0,0,150,150,150,0

g.DrawObject(f)

ArcShape is ugly, it lives from 0,0 to width,height
to test it you could make a button and change StartAngle or ArcAngle in steps of 3.14 / 4.0.

g.DrawRectangle 0,0,150,150

  Var a As New ArcShape
  a.X = 150/2
  a.Y = 150/2
  a.Height = 150
  a.Width = 150
  a.Segments = 0
  a.Rotation=0 '3.14 / 4.0
  a.StartAngle = Me.StartAngle
  a.ArcAngle = Me.ArcAngle
  a.BorderOpacity = 100
  a.BorderColor = Color.Black
  a.FillOpacity = 50
  a.FillColor = Color.Green
  g.DrawObject(a,0,0)

This because Y zero position is top left instead of bottom left and Y positive is down instead of up, right? or something different?

How are you defining the radius of the arc?

As far as I remember, yes. I have a degree in physics so trigonometry is for me like eating with a fork. It was confusing as heck.

What do you NORMALLY eat with? :crazy_face:

1 Like

Hello Daniel,
I found my test with ARC-shape
perhaps the example will help you.
I have now also bought a MINI M4
and am pleased with its speed.
My old 2014 iMac is considerably slower.

test-Arc-shape2.xojo_binary_project.zip (11.6 KB)