Brieg Brieg - 1 year ago 130
C++ Question

OpenGl/Glut: Draw arc/semi cycle giving first, second, third points and segments

After much deliberation and wandering into the unknown I make request to you: How to draw arc or semi-cyrcle in OpenGL or GLUT giving:

  • p1=(x1,y1) be the first point

  • p2=(x2,y2) the second point of the half-circle arc,

  • p3=(x3,y3) be the previous point preceding the first point.


Mathematic solve problem is HERE.

Answer Source

In your for loop you're incrementing your loop variable i by 1 with each iteration. Yet your calculation of curve parameter t does not take the number of steps into account. I'm kind of reluctant to give you the full solution, but here's a hint: You should divide by segments somewhere. Also segments likely is an integer, too, so you'll have to cast to float or double

Now before you start spraying your code with …/(float)segments think!

I want to you understand what you're doing there.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download