![]() ![]() With an understanding of the outer tangents, the graphic for the inner tangent should at least make sense: we have the same "green triangle" that we need to find a third point for, which is one of the two tangent points, and getting the other will then require using the opposite angle, rather than the same angle.įirst, rather than a third circle C3 inside C1 with radius $r1 - r2$, we want a circle C3 around C2 instead, with radius $r1 + r2$. ![]() (Also note, of course, that if you're using a vector based programming language, all of these things become "run the relevant function(s) on your vector inputs" instead of computing x and y coordinates independently) Inner tangents To get the two tangent points on the other side, we simply pick "the other angle", being the angle from the x-axis to the hypotenuse, minus the angle from the hypotenuse to the short edge: φ2 = atan2(c2.y-c1.y, c2.x-c1.x) - acos(short/hypotenuse) With that angle, we can now calculate our first circle's tangent point: t1x = c1.x + c1.r * cos(φ)Īnd our second circle's tangent point: t2x = c2.x + c2.r * cos(φ)Īnd we're done. However, one thing that's easy to overlook is that angles in computer graphics are universally relative to the x-axis, whereas this angle is relative to the hypotenuse, so we'll need to add it to the angle from the x-axis to the hypotenuse: φ = atan2(c2.y-c1.y, c2.x-c1.x) + acos(short/hypotenuse) While we don't know the third point, we do know all the side lengths: hypotenuse = dist(c1, c2)Īnd because we're dealing with a right-angled triangle, we also know: long = sqrt(hypotenuse*hypotenuse - short*short)īut we don't actually need to know how long this edge is, for the same reason: because we're dealing with a right-angled triangle, we can use trigonometry to find the angle we want using only the hypothenuse and short edge: φ = acos(short/hypotenuse) ![]() Treating the bigger circle as C1 with radius $r1$, and the smaller circle C2 with radius $r2$, we can create a new circle C3 inside C1 with radius $r3 = r1 - r2$, and then construct the green triangle: we know two of its points, but we don't know its third point, and knowing that third point lets us calculate the two outer tangent points. Let's look at the outer tangents first, because it's easier to intuit, after which the inner tangent image makes more sense: We can find both the inner and outer tangents between two circles with some simple mathematical observations. ![]()
0 Comments
Leave a Reply. |