Drawing elliptical arc with QPainter creates wrong angle

此生再无相见时 提交于 2019-12-12 05:07:01

问题


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.

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.

来源:https://stackoverflow.com/questions/37117032/drawing-elliptical-arc-with-qpainter-creates-wrong-angle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!