Skip to main content
Drnichol
Participant
July 16, 2026
Answered

How do I calculate projectile motion between two coordinates?

  • July 16, 2026
  • 4 replies
  • 38 views

I'm working on a simple projectile motion system and I'm trying to calculate the trajectory between two points.

I know the starting position (x1, y1) and the target position (x2, y2), but I don't know the launch angle or the initial velocity. The start and target positions can change every time, so I can't use fixed values.

What is the best mathematical approach or algorithm to calculate the correct launch angle and speed so the projectile reaches the target accurately? If there are multiple solutions or common methods, I'd appreciate an explanation or an example.

Thank you!

    Correct answer Mathias Moehl

    The problem is underdetermined: knowing only the start and target positions is not enough to calculate one unique launch angle and speed.

    You need one additional constraint, such as flight time, launch speed, angle, or maximum height. Depending on that choice, there may be multiple valid trajectories.

    @ShiveringCactus ’ answer is a helpful practical example: It resolves the ambiguity by assuming a fixed flight duration and arc height, although using ease() means the result is visually convincing rather than strictly physically accurate.

    For After Effects, my extension Easy Bounce is also a practical solution: you set the start, end, and approximate highest point, and it adjusts the motion path and timing to create a believable ballistic trajectory. 

    4 replies

    Mathias Moehl
    Community Expert
    Mathias MoehlCommunity ExpertCorrect answer
    Community Expert
    July 18, 2026

    The problem is underdetermined: knowing only the start and target positions is not enough to calculate one unique launch angle and speed.

    You need one additional constraint, such as flight time, launch speed, angle, or maximum height. Depending on that choice, there may be multiple valid trajectories.

    @ShiveringCactus ’ answer is a helpful practical example: It resolves the ambiguity by assuming a fixed flight duration and arc height, although using ease() means the result is visually convincing rather than strictly physically accurate.

    For After Effects, my extension Easy Bounce is also a practical solution: you set the start, end, and approximate highest point, and it adjusts the motion path and timing to create a believable ballistic trajectory. 

    Mathias Möhl - Developer of tools like BeatEdit and Automation Blocks for Premiere Pro and After Effects
    ShiveringCactus
    Community Expert
    Community Expert
    July 16, 2026

    Decades ago, someone made a tank game in After Effects.  I’ve been trying to find it.   

    But in the meantime, I think this expression should work:

    // 1. Reference layers
    targetLayer = thisComp.layer("Target NULL");
    targetPos = targetLayer.transform.position;

    // Use 'valueAtTime' on the layer's static/keyframes position at the In Point
    startPos = position.valueAtTime(inPoint);

    // 2. Define duration and map "time" to a progress variable "t" (0 to 1)
    duration = 1; // Flight duration in seconds
    t = clamp((time - inPoint) / duration, 0, 1);

    // 3. Linear interpolation using our normalized 't'
    linearX = ease(t, 0, 1, startPos[0], targetPos[0]);
    linearY = ease(t, 0, 1, startPos[1], targetPos[1]);

    // 4. Calculate the arc height (parabola) using 't'
    arcHeight = 300;
    parabola = 4 * t * (1 - t) * -1 * arcHeight;

    // 5. Combine linear path with the vertical arc offset
    [linearX, linearY + parabola]

    It’s not perfect, but might be a starting point to adapt

    ShiveringCactus
    Community Expert
    Community Expert
    July 16, 2026

    @Nishu Kushwaha - just noticed the Code layout that matches AE’s.  Nice.

    Nishu Kushwaha
    Community Manager
    Community Manager
    July 20, 2026

    Yah! That’s really convenient.