Trig Problem

This topic is 3559 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

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?

Share on other sites
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?

Share on other sites
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 line
P = [S * (C.S)/(S.S)] - C // center of circle projected onto line, back in "circle space" at the original origin

We then check if the line is too far away from the circle to intersect. This is true if (P.P) > r2 (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 = √[ r2 - (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 vector

Note 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.

Share on other sites
ninjackal,

Please provide some context for your question. Why are you trying to solve this problem?

1. 1
2. 2
3. 3
Rutin
22
4. 4
JoeJ
16
5. 5

• 14
• 29
• 13
• 11
• 11
• Forum Statistics

• Total Topics
631775
• Total Posts
3002284
×