Module org.dyn4j

Interface TimeOfImpactDetector

  • All Known Implementing Classes:
    ConservativeAdvancement

    public interface TimeOfImpactDetector
    Interface representing a time of impact algorithm.

    Sometimes called Continuous Collision Detection, implementing classes are used to detect collisions between Convex Shapes given their initial and final state of a time step. This information can then be used to solve a collision that was missed during that period.

    These algorithms are generally very computationally expensive.

    Since:
    1.2.0
    Version:
    3.1.5
    Author:
    William Bittle
    • Method Detail

      • getTimeOfImpact

        boolean getTimeOfImpact​(Convex convex1,
                                Transform transform1,
                                Vector2 dp1,
                                double da1,
                                Convex convex2,
                                Transform transform2,
                                Vector2 dp2,
                                double da2,
                                TimeOfImpact toi)
        Detects whether the given Convex Shapes collide given their current positions and orientation and the rate of change their position and orientation, returning the time of impact within an epsilon.

        If a collision is detected, the toi parameter will be filled with the time of impact and the separation at the time of impact.

        If a time of impact is detected, the time will be in the range [0, 1]. This can be used, along with the change and position and orientation, to place to the shapes at the time of impact. Note that the shapes will still be separated, by a small amount, at the time of impact.

        This method returns false if the shape do not collide.

        Parameters:
        convex1 - the first convex shape
        transform1 - the first convex shape's transform
        dp1 - the change in position of the first shape
        da1 - the change in orientation of the first shape
        convex2 - the second convex shape
        transform2 - the second convex shape's transform
        dp2 - the change in position of the second shape
        da2 - the change in orientation of the second shape
        toi - the TimeOfImpact object to be filled in the case of a collision
        Returns:
        boolean true if a collision was detected
        Since:
        3.1.5
      • getTimeOfImpact

        boolean getTimeOfImpact​(Convex convex1,
                                Transform transform1,
                                Vector2 dp1,
                                double da1,
                                Convex convex2,
                                Transform transform2,
                                Vector2 dp2,
                                double da2,
                                double t1,
                                double t2,
                                TimeOfImpact toi)
        Detects whether the given Convex Shapes collide given their current positions and orientation and the rate of change their position and orientation in the time range of [t1, t2] and returning the time of impact within an epsilon.

        If a collision is detected, the toi parameter will be filled with the time of impact and the separation at the time of impact.

        If a time of impact is detected, the time will be in the range [0, 1]. This can be used, along with the change and position and orientation, to place to the shapes at the time of impact. Note that the shapes will still be separated, by a small amount, at the time of impact.

        This method returns false if the shape do not collide.

        Parameters:
        convex1 - the first convex shape
        transform1 - the first convex shape's transform
        dp1 - the change in position of the first shape
        da1 - the change in orientation of the first shape
        convex2 - the second convex shape
        transform2 - the second convex shape's transform
        dp2 - the change in position of the second shape
        da2 - the change in orientation of the second shape
        toi - the TimeOfImpact object to be filled in the case of a collision
        t1 - the lower time bound
        t2 - the upper time bound
        Returns:
        boolean true if a collision was detected
        Since:
        3.1.5