Reputation: 421
I need to apply game physics in a way that's "backwards".
Even a clarification in terminology would be helpful.
Problem
Given a body's mass, maximum velocity, maximum force, and a set motion path (2d for now), I want to determine the forces needed to make the body follow the path while minimizing time.
To put it another way, an object's pathfinding is complete, now I want to apply inertia.
Ideas
both require sampling
Use a physics engine to control a dynamic body's motion, applying impulses to move along the path. Any time the body strays too far from the path, back up and begin slowing the body.
Use a physics engine to control a kinematic body attached via spring to a dynamic body. The kinematic body moves steadily along the path, until the dynamic body stretches the spring too far... again: back up and slow down.
Am I missing some common approach that I just haven't discovered? This is a little bit like inverse kinematics, but solving for different variables.
Upvotes: 0
Views: 146
Reputation: 11
a simple solution for most cases is: if the path has maximum curvature less than or equal to the maximum force divided by mass times the maximum velocity squared, than the speed is constant at the maximum speed, and the force is perpendicular to the motion of travel, with a magnitude proportional to the curvature. This is derived by setting the speed to the maximum allowed speed, and than using the osculating circle as a second order approximation for the path, and because acceleration(and therefore force) is locally independent of o(t^3) terms this approximation is exact. To generalize to higher dimensions one would have to take into account torsion, but the same concept applies.
Upvotes: 1
Reputation: 99154
I know this as "motion planning", and it's not trivial.
I'd probably try one (or both) of these approaches:
Evolutionary. I'd start with a trajectory (x(t), y(t)) in which the body comes to a full stop at each point in the sequence, or at each juncture of cubic curves; that's easy to calculate. Then I'd allow small random variations in thrust, selecting on adherence to the flight math and minimal total time, evolving until the total time leveled off.
Piecewise. For each cubic curve, calculate the range of starting velocities the body can have, and still stay close enough to the curve. Then let neighboring segments cinch up constraints on the handoff velocities, each segment seeking to minimise its own time.
Upvotes: 1