ninjackal 122 Report post Posted October 21, 2008 Given the equation of a line: X = X0 + Mx*k Y = Y0 + My*k where ( X0, Y0 ) is a point on the line and ( Mx, My ) is its' slope and k is a scalar, and given the path of a point orbiting about the origin: X = r*cos( S + W*dt ) Y = r*sin( S + W*dt ) where r is the distance of the point from the origin, S is the starting angle of the point, W is its' angular velocity as it orbits about the origin, and dt is the change in time In trying to solve for dt I get: X0 + Mx*k = r*cos(S + W*dt) k = (r*cos(S + W*dt) - X0)/Mx Y0 + My*k = r*sin(S + W*dt) k = (r*sin(S + W*dt) - Y0)/My and so, (r*cos(S + W*dt) - X0)/Mx = (r*sin(S + W*dt) - Y0)/My The value of every variable is known except for dt. Is there any way to determine the values of dt for which this equation is true? 0 Share this post Link to post Share on other sites
nilkn 960 Report post Posted October 21, 2008 From what I can see, your problem ultimately boils down to finding the intersection point(s) of an arbitrary line and a circle of radius r centered at the origin. dt is nothing more than an angular parameter specifying a point on the circle in polar coordinates.Maybe someone else here does, but I'm not sure of any easy way of doing this or of solving your particular equation. I hate to just drop a link, but have you looked at this MathWorld article which gives some equations? 0 Share this post Link to post Share on other sites
Zipster 2377 Report post Posted October 21, 2008 Like nilkn said, it looks to me like it's primarily a circle-line intersection problem.The first step is to project the circle's center onto the line. Since the circle is at the origin, this boils down to:C = (-X0,-Y0) // center of the circle in "line space"S = (Mx,My) // slope of the lineP = [S * (C.S)/(S.S)] - C // center of circle projected onto line, back in "circle space" at the original originWe then check if the line is too far away from the circle to intersect. This is true if (P.P) > r^{2} (the squared distance of the projected point from the center of the circle is greater than the squared radius of the circle). Otherwise, we can calculate the half-length of the chord created by the intersection using this:d = √[ r^{2} - (P.P) ] // note that if we didn't perform the previous check, the value inside the radical could be negative!The points of intersection are then:I = P ± Unit(S) * d // Unit() is a function that normalizes a vectorNote that if 'd' is zero, the line is tangent to the circle and in reality there's only one intersection point.Once you have the intersection points, you can use atan2 to determine the angle (or an equivalent function if you're not using the C++ math library). Set that angle equal to S + W*dt and you can easily solve for 'dt' from there. 0 Share this post Link to post Share on other sites
grhodes_at_work 1385 Report post Posted October 22, 2008 ninjackal,Please provide some context for your question. Why are you trying to solve this problem? 0 Share this post Link to post Share on other sites