We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Basically, I want to find this point (highlighted in blue):
Given the coordinates of the centers of both circles and both circles' radii, as well as the coordinates of the point on the inner circle.
The point on the inner circle is already selected randomly as follows:
float a = radians(random(0, 360));
float pX = innerCircRad*cos(a);
float pY = innerCircRad*sin(a);
Not sure if that helps at all, but that's what I'm doing.
Answers
Is this applicable?
http://math.stackexchange.com/questions/228841/how-do-i-calculate-the-intersections-of-a-straight-line-and-a-circle
Is this applicable? ;-) (just copied this phrase)
??
http://en.wikipedia.org/wiki/Spirograph#Mathematical_basis
Holy crap what?
Sorry, just took me a second to digest. It may be... I'll take a look.
I don't think so.
It would take me longer to digest this... ;-)
which of the two is it not? both?
Since the red line is a tangent to the smaller circle and the green line is perpendicular to it, then if we extend the green line it will pass through the centre of the smaller circle. So now we have two points on the line we need to find the line-circle intersection and there are several algorithms for that. The only other problem is that if we consider the green line to be of infinite length then there will 2 intersections of the outer circle and we have to decide which one to use.
Anyway the sketch below does all that for you - move the mouse round the centre of the smaller circle to see what I mean.
Although lengthy the code should be easy enough to follow and there is no need to understand how the line_circle_p code works - just accept it does what it says on the can. :\">
Thank you! This is perfect!