Equations to model tennis ball motion

AI Thread Summary
Modeling tennis ball motion requires adapting projectile equations to account for the ball's initial velocity at impact, as traditional equations assume the ball is at rest. The current approach yields inaccurate results when the ball is already moving, necessitating a revision of the equations to incorporate this factor. While existing resources on ballistics often neglect the influence of current velocity, they provide a solid foundation for understanding projectile motion. The discussion emphasizes the importance of first establishing correct equations before coding, as combining both processes can complicate problem-solving. Further research into ballistics with air resistance and Magnus force may also enhance the accuracy of the model.
mariano_donat
Messages
8
Reaction score
0
I'm creating a tennis game and at this point I'm trying to model ball motion. I found multiple lectures on projectiles equations of motion which seem to apply well for when ball is not moving, but they do not take into account the velocity may have at the time of impact. For example, I found a function that gives me the angle of launch so ball can impact a target point at a given speed. If the ball is not moving, it works well, however if it is, it yields incorrect results. So how would one go about plugging current velocity in projectile equations of motion? For reference, this is how the function to calculate the angle looks like:

Code:
func launchAngle(speed: Float, distance: Float, yOffset: Float, gravity: Float, angle0: inout Float, angle1: inout Float) -> Bool {
        angle0 = 0
        angle1 = 0
  
        let speedSquared = speed * speed
        let operandA = powf(speed, 4)
        let operandB = gravity * (gravity * (distance * distance) + (2 * yOffset * speedSquared))
  
        if operandB > operandA {
            return false
        }
  
        let root = sqrt(operandA - operandB)
  
        angle0 = atan((speedSquared + root) / (gravity * distance))
        angle1 = atan((speedSquared - root) / (gravity * distance))
  
        return true
    }
 
Physics news on Phys.org
If I were doing this, I would first get the equations right and then launch into the coding. Trying to do it all in one step is likely to be fraught, particularly if you are discussing the problem with a third party. The first thing anyone on PF would need to do is to unpack your code and write it in algebraic form so it would be the courteous thing to present your question in algebraic form.
Have you done any searching on Google for ballistics with air resistance included? There are hundreds of hits with the equations in.
 
For now, I was neglecting air resistance + Magnus force to keep things simple. Equations are right, it's just that I don't seem to be able to find those taking into account ball's current velocity. All of them act from the perspective of "launching" a projectile in rest. I've been watching Sebastian Lague videos on youtube which were really helpful to get the basic equations to work, but even those do not contemplate current motion. So yes, I've been searching/reading a lot for the last couple of weeks and still couldn't find such equations. Doing a search with ballistics also does not seem to yield equations taking this into account.
 
I have recently been really interested in the derivation of Hamiltons Principle. On my research I found that with the term ##m \cdot \frac{d}{dt} (\frac{dr}{dt} \cdot \delta r) = 0## (1) one may derivate ##\delta \int (T - V) dt = 0## (2). The derivation itself I understood quiet good, but what I don't understand is where the equation (1) came from, because in my research it was just given and not derived from anywhere. Does anybody know where (1) comes from or why from it the...
Back
Top