Class KinematicOps2D

java.lang.Object
org.bzdev.anim2d.KinematicOps2D

public class KinematicOps2D extends Object
Utility class for kinematic operations. These are simple operations involving constant accelerations along a path (including, of course, a straight line). Some involve solving a quadratic equation, which is easy, but a solution does not always exist and one has to choose between two possible solutions. plus allowing for round-off errors.

The methods this class provides are all static methods, and are intended to implement frequently used operations. These methods follow a naming convention. The first component of a method name is "dist", "time", "accel", or "v" to denote that the return value is a distance (positive or negative), a time interval (which must be positive, an acceleration, and a tangential velocity respectively. The second component is the word "Given". The third component is DVA, TVA, TVV, DVV, or VVA, where D indicates a distance argument, T indicates a time-interval argument, V indicates a velocity argument, and A indicates an acceleration argument. When there is one V argument the velocity is the one a the start. When there are two V arguments, the first is the velocity at the start and the second is the velocity at the end. all arguments and return values are double-precession numbers. A return value of Double.NaN indicates that the value cannot be computed.

  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    accelGivenDVV(double s, double v1, double v2)
    Get the acceleration needed to to traverse a specified distance along a path with constant tangential acceleration and specified initial and final tangential velocities.
    static double
    accelGivenTVV(double t, double v1, double v2)
    Get the acceleration needed to traverse a path assuming constant acceleration when the traversal takes a time t, with initial and final tangential velocities v1 and v2 respectively.
    static double
    distGivenTVA(double t, double v0, double a)
    Get the distance along a path when moving for a specified time with a specified tangent velocity and acceleration.
    static double
    distGivenTVV(double t, double v1, double v2)
    Get the distance traversed along a path assuming constant acceleration when the traversal takes a time t, with initial and final tangential velocities v1 and v2 respectively.
    static double
    distGivenVVA(double v1, double v2, double a)
    Get the distance along a path given the tangential velocities at the start and end of the path and the tangential acceleration along the path.
    static double
    timeGivenDVA(double s, double v0, double a)
    Get the time to travel along a path for given distance, given an initial tangential velocity, and constant tangential acceleration.
    static double
    timeGivenDVV(double s, double v1, double v2)
    Get the time needed to to traverse a specified distance along a path with constant tangential acceleration and specified initial and final tangential velocities.
    static double
    timeGivenVVA(double v1, double v2, double a)
    Get the time to traverse a distance along a path given the tangential velocities at the start and end of the path and the tangential acceleration along the path.
    static double
    vGivenDVA(double s, double v0, double a)
    Get the final velocity after traveling along a path for given distance, given an initial tangential velocity, and constant tangential acceleration.
    static double
    vGivenTVA(double t, double v0, double a)
    Get the final velocity along a path when moving for a specified time with a specified initial tangent velocity and with constant tangential acceleration.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • timeGivenDVA

      public static double timeGivenDVA(double s, double v0, double a)
      Get the time to travel along a path for given distance, given an initial tangential velocity, and constant tangential acceleration. Typically a positive distance corresponds to an increasing value of the path's parameter. The distance along the path will satisfy the equation s = v0t + (1/2)at2, where v0 is the initial velocity tangent to the path, a is the acceleration, and t is the time needed to cover the distance s.
      Parameters:
      s - the distance along the path
      v0 - initial velocity tangent to the path
      a - the acceleration tangent to the path
      Returns:
      the time to traverse the path; NaN if one will not move by the specified distance from the initial point
    • vGivenDVA

      public static double vGivenDVA(double s, double v0, double a)
      Get the final velocity after traveling along a path for given distance, given an initial tangential velocity, and constant tangential acceleration. Typically a positive distance corresponds to an increasing value of the path's parameter. The distance along the path will satisfy the equation s = v0t + (1/2)at2, where v0 is the initial velocity tangent to the path, a is the acceleration, and t is the time needed to cover the distance s. The final velocity is given by v = v0 + at.
      Parameters:
      s - the distance along the path
      v0 - initial velocity tangent to the path
      a - the acceleration tangent to the path
      Returns:
      the velocity when the end of the path is reached; NaN if the equations above cannot be satisfied.
    • distGivenTVA

      public static double distGivenTVA(double t, double v0, double a)
      Get the distance along a path when moving for a specified time with a specified tangent velocity and acceleration. The distance along the path can be positive or negative. Typically a positive distance corresponds to an increasing value of the path's parameter.

      The distance along the path will satisfy the equation s = v0t + (1/2)at2, where v0 is the initial velocity tangent to the path, a is the acceleration, and t is the time needed to cover the distance s.

      Parameters:
      t - the time spent traversing the path
      v0 - the initial velocity tangent to the path
      a - the acceleration tangent to the path
      Returns:
      the distance covered
    • vGivenTVA

      public static double vGivenTVA(double t, double v0, double a)
      Get the final velocity along a path when moving for a specified time with a specified initial tangent velocity and with constant tangential acceleration.
      Parameters:
      t - the time spent traversing the path
      v0 - the initial velocity tangent to the path
      a - the acceleration tangent to the path
      Returns:
      the distance covered
    • distGivenTVV

      public static double distGivenTVV(double t, double v1, double v2)
      Get the distance traversed along a path assuming constant acceleration when the traversal takes a time t, with initial and final tangential velocities v1 and v2 respectively. The distance is signed, with positive values typically corresponding to increasing values of the path parameter.
      Parameters:
      t - the time spent traversing the path
      v1 - the initial tangential velocity
      v2 - the final tangential velocity.
      Returns:
      the distance along the path that was traversed
    • accelGivenTVV

      public static double accelGivenTVV(double t, double v1, double v2)
      Get the acceleration needed to traverse a path assuming constant acceleration when the traversal takes a time t, with initial and final tangential velocities v1 and v2 respectively.
      Parameters:
      t - the time spent traversing the path
      v1 - the initial tangential velocity
      v2 - the final tangential velocity.
      Returns:
      the acceleration
    • timeGivenDVV

      public static double timeGivenDVV(double s, double v1, double v2)
      Get the time needed to to traverse a specified distance along a path with constant tangential acceleration and specified initial and final tangential velocities. The time interval returned must be positive.
      Parameters:
      s - the distance traversed
      v1 - the initial tangential velocity
      v2 - the final tangential velocity.
      Returns:
      the time to traverse the path; Double.NaN if no feasible value exists.
    • accelGivenDVV

      public static double accelGivenDVV(double s, double v1, double v2)
      Get the acceleration needed to to traverse a specified distance along a path with constant tangential acceleration and specified initial and final tangential velocities.
      Parameters:
      s - the distance traversed
      v1 - the initial tangential velocity
      v2 - the final tangential velocity.
      Returns:
      the tangential acceleration; Double.NaN if no feasible value exists.
    • timeGivenVVA

      public static double timeGivenVVA(double v1, double v2, double a)
      Get the time to traverse a distance along a path given the tangential velocities at the start and end of the path and the tangential acceleration along the path.
      Parameters:
      v1 - the initial tangential velocity
      v2 - the final tangential velocity.
      a - the tangential acceleration along the path
      Returns:
      the time it will take to reach a velocity equal to v2; Double.NaN if no such time exists
    • distGivenVVA

      public static double distGivenVVA(double v1, double v2, double a)
      Get the distance along a path given the tangential velocities at the start and end of the path and the tangential acceleration along the path.
      Parameters:
      v1 - the initial tangential velocity
      v2 - the final tangential velocity.
      a - the tangential acceleration along the path
      Returns:
      the time it will take to reach a velocity equal to v2; Double.NaN if no such distance exists