Do dat math!

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3612 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2005-06-22 18:50:38 +00:00
parent 681561c4bf
commit dfa9216b89
2 changed files with 38 additions and 9 deletions
@@ -21,6 +21,7 @@
package com.threerings.jme.sprite;
import com.jme.math.FastMath;
import com.jme.math.Vector3f;
/**
@@ -62,6 +63,26 @@ public class BallisticPath extends Path
}
}
/**
* Computes and returns the angle of elevation needed to launch a
* ballistic projectile at the specified velocity and have it travel
* the specified range (when it will once again reach the launch
* elevation).
*/
public static float computeElevation (float range, float vel, float accel)
{
return FastMath.asin(accel * range / (vel * vel)) / 2;
}
/**
* Computes and returns the flight time of a projectile launched at an
* angle previously computed with {@link #computeElevation}..
*/
public static float computeFlightTime (float range, float vel, float angle)
{
return range / (vel * FastMath.cos(angle));
}
protected Vector3f _curpos, _velocity, _accel;
protected float _duration, _accum;
protected Vector3f _temp = new Vector3f(0, 0, 0);