groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Groff] Problems with arcs and angles


From: G. Branden Robinson
Subject: Re: [Groff] Problems with arcs and angles
Date: Fri, 28 Apr 2017 11:32:51 -0400
User-agent: NeoMutt/20170113 (1.7.2)

At 2017-04-28T17:40:37+1000, John Gardner wrote:
> >
> > Does this help or did I manage to misunderstand you completely?
> 
> 
> I'm afraid so... the issue isn't with calculating radii, but calculating
> the `startAngle` and `endAngle`.

Right.  I got that but apparently communicated poorly.  Sorry.

To calculate the angles you need 3 things:
1. A library with arccos() and arcsin() functions.
2. The x and y coordinates of each point of interest, relative to the
   center.
3. The radius of the arc, measured from its center.

The arccos() and arcsin() functions answer the question: "Given this
point (x, y) on the arc of a circle, how do I find the angle that puts
me there?"

startAngle = arccos(x_start / radius)

endAngle = arccos(x_end / radius)

Depending on which quadrant the angles are in, you might find it easier
to use:

startAngle = arcsin(y_start / radius)

endAngle = arcsin(y_end / radius)

Or you can just use one of the functions and adjust the signs yourself.
This is what I was getting at when I talked about the inverse trig
functions not being one-to-one.  This is because, for example, both π/4
and 7π/4 have the same cosine, i.e., you get the same x coordinate from
those angles.  But if you take the algebraic signs of both your x and y
coordinates in to account, you should be able to get the angle values
you need.

Is this any sort of improvement?

Regards,
Branden

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]