 # Thread: Finding Y velocity at Time

1. ## Finding Y velocity at Time

Hi
I have a moving Ball.
The ball uses floating point coordinates.
I want to be able to determine the Balls final Yvelocity ahead of time.

The Ball moves forward by Cos and Sin, by having an Angle and a Speed.

Every Frame this happens:
- G is added to the Balls Gravity_
- Balls y coordinated is displaced Gravity nr of pixels

...
This here part is not directly related to my problem, but the Ball is also affected by Wind in the same maner as Gravity ( see above ).
I am able to determin the correct Xvelocity of the Ball ahead of time like this:
Cos( Angle ) * Speed + W * Time

This works accuratly...

...
However what i want is to be able to determin the final Yvelocity ahead of time.
I have tried to do something like this:
Sin( Angle ) * Speed + G * Time

But it doesnt seem to produce results remotely accurate.

...
I want to be able to determine the Balls final Yvelocity ahead of time.
How can i solve this?
Ami doing something wrong?  Reply With Quote

2. Longshot, but try adding brackets to make sure the calculation is handled correctly, eg (Cos( Angle ) * Speed) + (W * Time)  Reply With Quote

3. Hmmm, ive been looking into this all day and am not getting any wizer.
- It appears that Gravity_ and Wind_ works the same way and works consistently.
- Both Wind and Gravity seem to be working correctly, and all other equations which include Wind or Gravity ( all other equations in general ) work correctly

- When i check the Balls Yvelocity/ Yoffset after X Frames, i get an apparent correct result between 0 and 1 ( it looks consisten relative to how the Ball moves at Frame X ), but the equation outputs a Yvelocity around 10. It is not remotely correct.

...
Could there be some problem with the + or -, since the coordinate origin ( 0,0 ) startes at the top left instead of bootom left?
Does it matter if i use Sin or Cos ( I guess im gonna use Sin since i want Yvelocity )?
Any ideas what could be wrong?

I would hate to disect the expression and cross check every value in it and every relevant event, but it looks like im heading in that direction   Reply With Quote

4. Take your original formula but replace sin(Angle) with -sin(Angle). MMF2 has 0,0 at the top left, but most maths are done with 0,0 at the bottom left, which means your Y coordinate is always going to be inverted. This is why when you're making a 360 degree movement you do X = X + cos(angle) but Y = Y - sin(angle). You need to subtract sin() because it assumes 0,0 is at the bottom left.  Reply With Quote

5. Sweet, thanks Jacob this works!

0 - Sin( Angle ) * Speed + G * Time

And this also works

-1 * Sin( Angle ) * Speed + G * Time  Reply With Quote

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•