It is correctly solves this query: Draw in OpenGL/Glut circle tangent to a section carried AB passing through B and C.

491 Views Asked by At

Welcome.

To do that i only have got:

  • point A(Ax,Ax)
  • point B(Bx,By) - start
  • point C(Bx,By) - end

Let's compute:

And it's good way? If no, why?

So to draw a cricle we need radius and center and angle. To get that im doing:

Let I((B.x + C.x) / 2, (B.y + C.y) / 2) be the middle point of [BC] and I'(I.x + I.y - C.y, I.y + C.x - I.x) (90° rotation of C around I).

Then the perpendicular to (BC) going through I is I + tII' (for any real number t).

Likewise withB' be the 90° rotation of A around B, the perpendicular to (AB) going through B is B + uBB' (for any real number u).

So i have center and radius. One think is left i need start angle and end angle.

startAngle = atan2(B.y - centerArc.y, B.x - centerArc.x);
endAngle = atan2(C.y - centerArc.y, C.x - centerArc.x);
  • Actualy atan2 making significant confusion - is there any other way to calculate the start and eng angle?

And now im actualy stuck becouse I have problems with appropriate term direction to draw a circle.

This gif show how it should be: link to gif Any ideas?

1

There are 1 best solutions below

5
On

Circles tangent to a given line ($AB$) at a given point ($B$) are all related by a similarity transformation centered at the point.

To make one of those circles go through a second point ($C$ in this question), draw any tangent circle at $B$ and its intersection $X$ with line $BC$, then rescale that circle by a factor of $CB/XB$ to make it reach $C$.

From this construction it follows that no square roots are necessary in the formula for the circle when using Cartesian coordinates. For example, if the line were $y=0$ and $B=(0,0)$ then the family of circles is $x^2 + (y-a)^2 = a^2$ or $x^2 + y^2 - 2ay = 0$, and to make this pass through $(p,q)$, set $x=p, y=q$ in the equation to determine $a$.