# Trajectory of a spinning ball

How do I would precalculate trajectory of a kicked ball, when it's spinning?

I'm applying spinning using simplified Magnus effect every frame like this and it works:

acceleration += swerve × velocity


My question is: do the equation below for calculating object trajectory can be extended to include the ball spinning?

position = start + 0.5*acceleration*time^2 + velocity*time;


I'm using Euler integration and ball moves fine. I just want to know how to predicts ball's movement path.

There is such an equation, but it's not easy to obtain. Because the magnus effect depends on the ball's current velocity, it changes when external forces are applied. You cannot calculate the position of the ball by linearly summing the contributions of different forces. If you were hoping you could simply add a few terms to x(t) = ½ a t² + v t, you're out of luck.

Numerical integration is a valid way of predicting the balls trajectory and doesn't require you to actually move the ball if you use a different set of variables. If you want to use a direct approach, you might want to use a tool that can solve a system of differential equations. I used Mathematica to obtain the following equations for a ball starting off with a set velocity and being subject to a gravitational acceleration -g in the z-direction and a magnus force Fmag = c ω × v, for brevity condensed into: amag = r × v.

system = {
vx'[t]==ry vz[t]-rz vy[t],
vy'[t]==rz vx[t]-rx vz[t],
vz'[t]==rx vy[t]-ry vx[t]-g,
vx[0]==vx0,vy[0]==vy0,vz[0]==vz0
};
DSolve[system,{vx,vy,vz},t]
Integrate[%,t]


With a few tweaks, assumptions and some rewriting here and there, the result still looks dreadful, but is computationally not all that expensive.

If you didn't think these equations were getting out of hand already, you most likely will if you were to add more forces to the model. Unless you feel the need for the accuracy and speed these equations can provide, I recommend sticking with code that fellow mortals can read and maintain.

• Yes, I've hoped it would be simpler. Will stick with numerical integration then. Thanks for help! – HankMoody Dec 21 '14 at 14:25
• I am trying to predict the falling spot of thrown objects at jmonkey engine, do you think that can help me? – Aquarius Power Jan 18 '15 at 15:57

First create a vector. It's angle is equal to ball spin speed (degrees per frame) plus the balls trajectory angle ( looking down from the sky). Set the magnitude to however much you want it to effect the trajectory of the ball. Add this vector to the balls vector, or position if you don't use vectors. Probably a good idea to make the magnitude diminish over time, that way it won't turn forever. This can be applied in 2d games, and can be modified to be used in the third dimension by doing the same process from the side.

• I know, how to move a ball due to spin but I don't know how to predict ball's trajectory without actually moving it. – HankMoody Dec 18 '14 at 18:04