Sign in to follow this  

Trig Problem

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites

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

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this