The equation describes accelerating at a constant rate of 1 from a starting velocity v0 to an intermediate velocity vm, and then at the same rate of 1 (but possibly in a different direction) from vm to a final velocity vf. The desired displacement resulting from this trip is r.
Essentially we have position and velocity endpoint conditions, and a limit on how fast we can accelerate. My hypothesis is that the quickest path connecting the endpoints will be two parabolas (with the max acceleration on each) that fit the ends and match position and velocity where they meet.
I will probably put this problem on the back burner for a bit, but before doing so I thought I'd at least produce some graphs to get a better feel for it. I wrote a quick program that uses OpenGL to produce graphs of velocity space.
The program takes in a v0 and vf pair. Each point on the graph is a candidate vm; the program uses it to evaluate the right-hand side of the equation to give the r corresponding to that solution.
Lines of constant rx are drawn in red and lines of constant ry in green. If they were labeled, you could find a rough solution by locating the red line and green line that correspond to the desired r, and then locating an intersection between them. The position of the intersection is the value for vm that solves the equation.
Here is the simplest case, where the starting and ending velocities are both zero:

(0, 0) to (0, 0)
The program dices the screen up into squares a few pixels on a side. For each square, it evaluates r at the four corners, then draws two textured quads additively over it. The first is drawn in red and uses rx as the Z coordinate. I've set OpenGL to map the Z value into a repeating one-dimensional texture which contains a few white pixels followed by a bunch of black ones. This creates the periodic lines. The texture is mipmapped to cut down on aliasing, so when the lines get really thin they fade out rather than dissolving into sparkles. The second quad is drawn in green, using ry as the Z coordinates for the quad corners.Here's a slightly more complicated example, with starting velocity of zero:

(0, 0) to (8, 0)
It looks like there is still a unique solution for every given displacement. The exception to this is on the line from (0, 0) to (8, 0) itself (drawn in yellow and faintly visible over the green); any point on there will give the same r.Let's mix things up a bit more:

(6, -2) to (6, 2)
Now there are closed loops of constant rx. There are some green and red lines that cross each other twice, indicating that for those values of r there are two solutions.Here's a diagonal movement in velocity space:

(5, 0) to (10, 5)
Now there are some red and green lines that cross each other three times! So there are at least some cases that have three solutions. I don't know if there are situations with four solutions. The minimum-time solution is the one closest to v0 and vf.If nothing else, this would make a really wild screensaver, if you animated v0 and vf to bounce around the screen.
No comments:
Post a Comment