Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Find acceleration to stop at target in frictionless 2D space

  1. Jun 7, 2013 #1
    This is a problem that's appeared in a game I am writing, and is a bit beyond the mechanics I can sort-of remember from highschool.

    The context is I have an object in 2D space which has a position [itex]p[/itex] and a velocity [itex]u[/itex], and a goal position [itex]G[/itex] I want that object to be in as soon as possible. At each time step, I can add an acceleration [itex]a = xA[/itex], where [itex]A[/itex] is the maximum acceleration and [itex]-1 \leq x \leq 1[/itex]. When the object reaches the goal position, its velocity should be 0.

    I need to define a function [itex]f[/itex] with produces an acceleration [itex]a = f(G, A, p, u)[/itex]. This function should yield a sequence of states [itex]s_0, s_1, s_2 \ldots s_n[/itex] with the smallest possible length [itex]n[/itex], where each state [itex]s_i[/itex] is of the form [itex]s_i = (\mbox{position}, \mbox{velocity})[/itex].

    The sequence of states must meet the criteria:

    [itex]s_0 = (p, u) \\

    s_n = (G, 0) \\

    s_{i+1} = (\mbox{position}(s_i) + \mbox{velocity}(s_i), \mbox{velocity}(s_i) + f(G, A, \mbox{position}(s_{i+1}), \mbox{velocity}(s_i)))[/itex]

    Also, [itex]-A \leq f(G, A, p, u) \leq A[/itex]

    It's pretty trivial in one dimension, but extrapolating it to two dimensions is difficult because of the constraint on maximum acceleration.

    My one dimensional solution:

    [itex]f(G, A, p, u) = \begin{cases}
    \mbox{min}(u + A, v) & u < v \\
    \mbox{max}(u - A, v) & u > v \\
    u & \mbox{otherwise}\end{cases}[/itex], where [itex]v=\sqrt{2A(G - p)}[/itex]

    My reasoning here is that it should find out the largest possible velocity the object can travel at while still being able to slow and stop at the target, and then depending on whether that velocity has been exceeded or not the object will either accelerate or decelerate by the acceleration limit.

    I'm at a loss as to how to extrapolate this into two dimensions, any help is appreciated.
     
  2. jcsd
  3. Jun 7, 2013 #2

    mfb

    User Avatar
    2016 Award

    Staff: Mentor

    I think we had a similar question here one year ago (?), I don't remember if there was some reasonable solution.

    In the continuous case, the best trajectory always uses the maximal acceleration. I would expect that the stepwise version will do the same, maybe with 1-2 steps as exception.

    To restrict the search space: I would expect that three periods of constant acceleration direction will give a reasonable approximation to the ideal path. This leaves 5 degrees of freedom (three directions and two times), with 4 constraints (final position and velocity), so 1 parameter can be optimized.
     
  4. Jun 7, 2013 #3
    It would make sense that a decent method would be to eliminate tangential velocity first, and then solve it as the one dimensional case along the radial line (treating the goal as the centre). So the three stages you describe would be to:

    1. Eliminate tangential velocity by accelerating in the opposite direction
    2. Accelerate directly towards goal until the critical point is reached where deceleration is required
    3. Acelerate in the opposite direction of motion to stop on the goal

    This will certainly solve the problem of reaching the target with a final velocity of zero, but is it optimal? It will probably be good enough for my application, although I am interested in knowing if an optimal general solution exists (assuming this is not it).

    An alternative I may test could be finding a way of determining the number of steps required to reach the target in the 1D case as a function of the maximum acceleration, and then balancing what ratio of the acceleration is allocated to solving the 1D case on both the X and Y axis such that they both reach the target at the same time.
     
  5. Jun 7, 2013 #4
    Can you brute force it? Just estimate based on two 1D problems, and try some iterative solution? Granted, I haven't really thought it through.

    edit:
    I think this is an inverse kinematics problem. They can get a lot more complicated in general.
    https://en.wikipedia.org/wiki/Inverse_kinematics
     
  6. Jun 8, 2013 #5

    mfb

    User Avatar
    2016 Award

    Staff: Mentor

    I am sure it is not, and it gives other issues, too - the tangential direction changes as the object moves. You could try to get rid of angular momentum first (this gives constant acceleration in one direction as first step), but I think my proposed method is more general and will find a better solution in most cases.

    There is an optimal solution, the problem is just to find it without excessive numerical simulations for every set of parameters.

    Hmmhmm... could lead to interesting results.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Find acceleration to stop at target in frictionless 2D space
  1. Acceleration in space? (Replies: 10)

Loading...