Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Thrump

math problem

This topic is 6504 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

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

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!