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

## 3 Answers

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)=\frac{1}{2}at^2+vt\$$, 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 $$\F_{mag}=c\omega\times v\$$, for brevity condensed into: $$\a_{mag}=r\times 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.

Direct equations according to Mathematica:

\begin{align} x(t) =&\frac{1}{r^3}(-\frac{1}{2}t(grtr_xr_z+2grr_y-2rr_xr_yv_y(0)-2rr_xr_zv_z(0)-2rr^2_xv_x(0))+\\ &sin(rt)(gr_y+r^2_yv_x(0)-r_xr_yv_y(0)+r^2_zv_x(0)-r_xr_zv_z(0))-\\ &\small{\frac{cos(rt)(gr_xr_z+r^2_xr_yv_z(0)-r^2_xr_zv_y(0)+r^3_yv_z(0)-r^2_yr_zv_y(0)+r_yr^2_zv_z(0)-r^3_zv_y(0))}{r})}\\ y(t)=&\frac{1}{r^3}(-\frac{1}{2}t(grtr_yr_z-2grr_x-2rr_xr_yv_x(0)-2rr_yr_zv_z(0)-2rr^2_yv_y(0))-\\ &sin(rt)(gr_x+r^2_x(-v_y(0))+r_xr_yv_x(0)-r^2_zv_y(0)+r_yr_zv_z(0))-\\ &\small{\frac{cos(rt)(gr_yr_z-r_xr^2_yv_z(0)+r^2_yr_zv_x(0)+r^3_x(-v_z(0))+r^2_xr_zv_x(0)-r_xr^2_zv_z(0)+r^3_zv_x(0))}{r})}\\ z(t)=&\frac{1}{r^3}(-\frac{1}{2}tr_z(grtr_z-2rr_xv_x(0)-2rr_yv_y(0)-2rr_zv_z(0))+\\ &\small{\frac{cos(rt)(gr^2_x+gr^2_y-r_xr^2_zv_y(0)+r_yr^2_zv_x(0)+ r^3_x(-v_y(0))+r^2_xr_yv_x(0)-r_xr^2_yv_y(0)+r^3_yv_x(0))}{r}}-\\ &sin(rt)(r^2_x(-v_z(0))+r_xr_zv_x(0)+r_yr_zv_y(0)-r^2_yv_z(0)))\end{align}

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

The trajectory will be the same despite the angular velocity of the ball, ok? Unless you take air resistance into account

• "Unless you take air resistance into account" — given that this question from 5 years ago specifically mentions modelling the Magnus effect, yes, taking air resistance into account is exactly what they're trying to do. – DMGregory Sep 15 '19 at 12:37