0

I'm working on a program which is displaying cgm graphics. For an elliptical arc, I get vectors to the start and end angles so after I calculate the angles and try to use them in an arc, I am getting the wrong angles drawn.

In the image below :

  • The gold lines show the vectors I get.
  • The red arc is the ellipse I get trying to draw the image with the angles given.
  • The green arc which I get is the image with the ellipse changed to a perfect circle.

enter image description here

Is there a way I can correct this?

Brief exapme of code:

/*213 and 113 are the angles calculated from the vectors from the center blue mark at(300, 200) to the points (-75, -50) and (75, -50) which are shown by the dark yellow lines*/  

QPainter p;

//draw elliptical arc     
p.drawPie(200,150, 200, 100, 213*16, 113*16);

//draw circular arc
p.drawPie(250,150, 100, 100, 213*16, 113*16);

edit: I found my issue. My geometry was off by assumming the angle was the same for circles and ellipses. Thanks to @KubaOber for mentioning that.

edit 2: I am now in need of assistance in finding the correct formula for calculating the angle ot the vector for an ellipse. If someone can point me in the correct direct. Thanks.

Gene
  • 3
  • 4
  • Please show a minimal code example. There's no way to answer your question otherwise. All we know is that you're doing something wrong. I know how to do it right, but it won't help you, because there's many ways of doing it right and it's unlikely that my way will align with your requirements. – Kuba hasn't forgotten Monica May 09 '16 at 13:55
  • @KubaOber I added a brief code example. I don't think I'm doing anything wrong but Qt is ding its' math weirdly. It seems their math is "stretching" the ellipse after applying the start and stop angles. I want to know the best way to correct this. Thanks. – Gene May 09 '16 at 14:28
  • 1
    what's the green rectangle? It seems you have not done the affine transformation from the widget coordinate to the green rectangle coordinates – UmNyobe May 09 '16 at 14:46
  • @UmNyobe The green rectangle is the bounding box of the ellipse for my visual benefit. It doesn't affect anything with the ellipse. – Gene May 09 '16 at 15:17
  • Angles in an elliptical arc have a different meaning than in a circular arc. I'd say it works as designed, if perhaps the design is a bit counterintuitive. – Kuba hasn't forgotten Monica May 09 '16 at 15:28
  • @KubaOber That makes sense. Do you know the basic direction I should be headed in such as the equations I should be looking up. Thanks. – Gene May 09 '16 at 16:02
  • It should be easy once you think of an ellipse as a flattened circle. – Kuba hasn't forgotten Monica May 09 '16 at 17:22
  • @KubaOber Do you know the correct formula or a reference I can look at. I have not had much luck with my particular situation. Thanks. – Gene May 12 '16 at 20:16

0 Answers0