Author |
Message |
|
c_plus_plus My Face Hertz
Active Member
Joined: 30 Jan 2006 Posts: 575
|
Posted: 18 Oct 2006 10:00:48 pm Post subject: |
|
|
I'm trying to make a game with some physics in it. I'm trying to figure how to make my object change directions when forces are aplied. Here is an example I need to be able to calculate using a general formula.
My object is going at 12 px/frame at an angle of 12 degrees.
A force capable of accelerating the object at 5 px/frame pushes the object from an angle of 98 degrees.
How do I find the new speed/heading of the ball? |
|
Back to top |
|
|
JoeImp Enlightened
Active Member
Joined: 24 May 2003 Posts: 747
|
Posted: 18 Oct 2006 11:24:55 pm Post subject: |
|
|
Where are your angles measured from, the horizontal? What about the second one? Draw me a diagram of what is happening. Also,
Quote: A force capable of accelerating the object at 5 px/frame pushes the object ..
5 px/frame is a velocity not an acceleration. I assume you mean 5px/frame^2?
So uh yea, draw a nice diagram and I'll figure it out for you. Maybe make up some easy equations you can use. Time to put my physics to work.
Last edited by Guest on 18 Oct 2006 11:28:03 pm; edited 1 time in total |
|
Back to top |
|
|
leofox INF student
Super Elite (Last Title)
Joined: 11 Apr 2004 Posts: 3562
|
Posted: 19 Oct 2006 09:50:32 am Post subject: |
|
|
5 px per frame is HUUGE for accelaration.
Also, it's smarter to store your vectors as x | y, so you dont have to use sin( (slooow) every time you need the components.
I'm not exactly sure what your problem is, but you probably just need to add the vectors, which is a piece of cake if you have the components. |
|
Back to top |
|
|
JoeImp Enlightened
Active Member
Joined: 24 May 2003 Posts: 747
|
Posted: 19 Oct 2006 12:46:32 pm Post subject: |
|
|
He says there's acceleration, so it might not be so easy. |
|
Back to top |
|
|
c_plus_plus My Face Hertz
Active Member
Joined: 30 Jan 2006 Posts: 575
|
Posted: 19 Oct 2006 03:15:45 pm Post subject: |
|
|
I think I've got it down now. I did separate the horizontal speed and vertical speed. This was mainly for gravity, so I simply added the velocity each frame to my vertical speed variable. If the force came from a different direction I guess I could simply add the acceleration to the individual components. |
|
Back to top |
|
|
trigkid213
Member
Joined: 30 Mar 2006 Posts: 208
|
Posted: 19 Oct 2006 04:15:27 pm Post subject: |
|
|
c_plus_plus wrote: I'm trying to make a game with some physics in it. I'm trying to figure how to make my object change directions when forces are aplied. Here is an example I need to be able to calculate using a general formula.
My object is going at 12 px/frame at an angle of 12 degrees.
A force capable of accelerating the object at 5 px/frame pushes the object from an angle of 98 degrees.
How do I find the new speed/heading of the ball?
[post="89953"]<{POST_SNAPBACK}>[/post]
I'm assuming your object is following this path:
[attachment=1017:attachment]
Your velocity is the vector {12cos(12),12sin(12)}. If your object is a point, its initial point is {X,Y}, and the frame # is F, then a simple way to display it is:
:{X,Y}+F{12cos(12),12sin(12)}
:pt-on(Ans(1),Ans(2))
Of course it's faster if you don't use lists but this is the easiest way to show it. Now for acceleration. The acceleration vector is going to be {5cos(98),5sin(98)}. The velocity at a given frame will be {12cos(12),12sin(12)}+F{5cos(98),5sin(98)}. You can display the point like this:
:{X,Y}+F{12cos(12),12sin(12)}+.5F^2{5cos(98),5sin(98)}
:pt-on(Ans(1),Ans(2)}
Hope this helps. I used the Newtonian kinematic equations, which you can find here.
Last edited by Guest on 19 Oct 2006 04:15:59 pm; edited 1 time in total |
|
Back to top |
|
|
leofox INF student
Super Elite (Last Title)
Joined: 11 Apr 2004 Posts: 3562
|
Posted: 20 Oct 2006 01:18:02 pm Post subject: |
|
|
you can better use a loop, then update the variables each time. That way, you will only need to add from the previous factors (which is faster and easier) instead of use quadratics all the time. |
|
Back to top |
|
|
c_plus_plus My Face Hertz
Active Member
Joined: 30 Jan 2006 Posts: 575
|
Posted: 20 Oct 2006 02:35:20 pm Post subject: |
|
|
I used the loop. It does work well. One interesting factor is the diference in interpreted speed of the calcs. For example, on the 84+SE the ball moves faster than the 84+. I would expect the 83+ to go extremely slow. |
|
Back to top |
|
|
leofox INF student
Super Elite (Last Title)
Joined: 11 Apr 2004 Posts: 3562
|
Posted: 20 Oct 2006 03:16:16 pm Post subject: |
|
|
For something like this, the screen routines are the slowest. Screen routines are the same speed on all calcs, the slower 84+ might have a slower driver.
Keep an eye out for http://www.unitedti.org/index.php?showtopic=5754, it seems the same as what you're making |
|
Back to top |
|
|
alexrudd pm me if you read this
Bandwidth Hog
Joined: 06 Oct 2004 Posts: 2335
|
Posted: 20 Oct 2006 05:00:18 pm Post subject: |
|
|
c_plus_plus wrote: For example, on the 84+SE the ball moves faster than the 84+. I would expect the 83+ to go extremely slow. [post="90003"]<{POST_SNAPBACK}>[/post] That doesn't make sense - the 84+ and 84+SE have the same processor (as well as the 83+SE). Maybe one of them has the toggle for 6Mhz instead of 15 set? |
|
Back to top |
|
|
Sage Orator
Advanced Member
Joined: 23 Apr 2006 Posts: 337
|
Posted: 20 Oct 2006 05:27:27 pm Post subject: |
|
|
It may be a memory difference. That's usually the reason for a slight difference in my calcs. They're a lot closer when my SE's memory is around the same as my 84+. |
|
Back to top |
|
|
trigkid213
Member
Joined: 30 Mar 2006 Posts: 208
|
Posted: 21 Oct 2006 04:03:53 pm Post subject: |
|
|
Leofox wrote: you can better use a loop, then update the variables each time. That way, you will only need to add from the previous factors (which is faster and easier) instead of use quadratics all the time.
I know, I just wanted to show where the physics was coming from.
Sage Orator wrote: It may be a memory difference. That's usually the reason for a slight difference in my calcs. They're a lot closer when my SE's memory is around the same as my 84+.
[post="90021"]<{POST_SNAPBACK}>[/post]
Yeah, if you take two identical calculators, except one has its memory almost full, there will be a noticeable difference even in homescreen calculations. |
|
Back to top |
|
|
|