math problem

Started by
8 comments, last by Thrump 23 years, 4 months ago
Hello. Have a math problem for some physics in my game... solve for theta.. a*cos(theta) - b*sin(theta) = c a,b and c are known.... I need to isolate theta... brain drying up... gasp! there''s probably more than one solution for theta 2, due to the inverse of sin and cos not being functions... i don''t know..
Advertisement
Actually, it may help to know what I''m doing. A projectile is being shot at some known speed. I know the start and end positions also, but don''t know the components of the velocity. I eventually got it down to solving the above equation. Using the theta value, I can fine the components of the velocity. If anybody has any questions, I''ll be sure to answer them. Thanks!
good news
Hey, I found the solution at www.quickmath.com
really cool site

bad news
it''s unsolvable with my choice of a, b and c... oh well... gotta think this out a bit more i think
Are you looking at a projectile that is not affected by gravity?

If so you only need to find the difference between your two points and use the ratio of the magnitude of the distance to that of each component to determine you velocity component.

X is the distance between your too points
x1, x2, and x3 are the three components of that distance.
V is the magnitude of you velocity.
V * x1/X is the magnitude of your velocity in the direction of x1. And the same is true for all you components.

If your dealing with gravity as well, its a bit more complicated.

Chambs
Chambs
Sorry, yes I do need the projectile affected by gravity. In school we did all sorts of these problems, but trying to figure out this one I keep getting hard to solve equations. Anyway, this is what I start with...

dx = |velocity|*cos(theta)*time
dy = |velocity|*sin(theta)*time + -9.8/2*time^2

solving for time in the dx case, you get only one unknown variable, theta. So there''s an answer, I just can''t get theta isolated. Taking out the gravity term simplifies it a lot. (i can actually do that... hehe )

Thanks for the help.
I think I found the 2d solution... it''s a huge equation, so I''m not going to type it unless anybody is interested. Thanks for the help chambs. Now on to 3d...
Oh, so you just need a 2d solution as well? Thats not so bad.

Try starting with:

|velocity|^2 = dx^2 + dy^2
t = x/dx
y(final) = y(initial) + dy*t - g/2 * t^2

You should be able to solve those three equation for dy and dx. The only problem is you will get two answers. Both answers could be right. There is often a low fast path and a high slow path. You will have to choose between them.

Hope this helps.



Chambs
Chambs
Yeah, I was just about to say that that's not how you get the c value. It's like the Pythagorean theorem: c^2 = a^2 + b^2, or, solving for c, c = sqrt(a+b).

Since a and b are your x and y values, respectively, this makes it c = sqrt(x+y).

But you know x, y, and c. Here's the simple way to get theta:
theta = arctan (y/x).
Once again, this has to do with right triangles:

ASCII ART ON
EDIT: D'OH! ASCII art doesn't really work in here...
ASCII ART OFF

(note that th is theta)...
Since tan = opp/adj (or y/x for any triangle regardless of quadrant), to get theta, you simply find the inverse tan (arctan or tan^(-1)) of theta.

I hope that helped.

Excuse me whilst I conquer Earth...

Commander M
(a.k.a. Crazy Yank)
http://commanderm.8m.com
CmndrM@gdnmail.net

Edited by - CmndrM on November 30, 2000 3:21:10 PM
CmndrM, a and b are not x and y. They are simply known. This equation came from a long substitution process, and really doesn''t mean much...

Chambs, yeah, I thought there was a simpler way to do it. I got it working now, but it''s way too complicated. I may go back and change it to your method. To get it to 3d, I rotate the difference of the end point and start point, which then yields the simple 2d case. After I get Vx and Vy, I then rotate Vx by the original rotation and get the real Vx and Vz.

Seems to work...
Whoops, my bad! I guess I just misinterpreted what you were asking. Oh well...

Currently consolidating my power...

Commander M
(a.k.a. Crazy Yank, digitalp1aya, and countless other things)
http://commanderm.8m.com
CmndrM@gdnmail.net

This topic is closed to new replies.

Advertisement