Module org.dyn4j

Class Force


  • public class Force
    extends Object
    Represents a force.
    Since:
    1.0.0
    Version:
    5.0.0
    Author:
    William Bittle
    • Field Detail

      • force

        protected Vector2 force
        The force to apply
    • Constructor Detail

      • Force

        public Force()
        Default constructor.
      • Force

        public Force​(double x,
                     double y)
        Creates a new Force using the x and y components.
        Parameters:
        x - the x component
        y - the y component
    • Method Detail

      • set

        public void set​(double x,
                        double y)
        Sets this Force to the given components.
        Parameters:
        x - the x component
        y - the y component
      • isComplete

        public boolean isComplete​(double elapsedTime)
        Returns true if this force should be removed.

        Implement this method to create Force objects that are not cleared during the accumulation step.

        The default implementation always returns true.

        Parameters:
        elapsedTime - the elapsed time since the last call to this method
        Returns:
        boolean true if this force should be removed
        Since:
        3.1.0
      • getForce

        public Vector2 getForce()
        Returns the force vector.
        Returns:
        Vector2