0

I am working on a program which draws shapes based on a cgm file input. I am trying to draw elliptical arc and it gives the opening portion in terms of a start and end vector from the center of the arc. I need help calculating the angle to the vector so I can draw.

I have been trying to use the standard atan2(y/x) but then I found it is valid for circles and not ellipses.

This image gives an example of what I'm trying to do. I am looking for angles A and B.

edit: This is related to my other question here. (Also note, this question is based on the math behind my problem while the other question was for programming help with qt.)

The wiki page on ellipses kind of shows why the math isn't working but I'm not sure how to implement it.

Elliptical Angle Example

kennytm
  • 510,854
  • 105
  • 1,084
  • 1,005
Gene
  • 3
  • 4
  • What are the expected values of A and B? Is the size of the ellipse given? – kennytm May 16 '16 at 18:32
  • @kennytm I'm not sure what the exact values are. Yes the size of the ellipse is given. I update the original question with a link to my other question on which this is built on. – Gene May 18 '16 at 13:07

1 Answers1

0

The angles A and B you were drawing in your picture in fact have nothing to do with the ellipse.

Just calculate once the angle between the x-axis and the line from origin to point (75,50). This is given by arctan(50/75) = 33.69°. And by symmetry, it is the same as the angle to point (75, -50).

Then, by simple trigonometry, for angle A you get A = 360° - 33.69°, whereas for B you get B= 180° + 33.69°.

Considering A, this is the same information that is obtained by atan2(-50, 75). However, the result of atan2 is in (i) in radians and (ii) in the range [-pi, pi]. You could add 2*pi and express it in angles and you get the same result as above.

davidhigh
  • 14,652
  • 2
  • 44
  • 75
  • That is what I tried originally but I'm using the results to draw the angle in qt using the drawArc function [qpainter](https://doc.qt.io/qt-4.8/qpainter.html) class. If I use those answers the arc is not drawn correctly. – Gene May 18 '16 at 13:00