A RigidBodyCollision generated by a Connector.

Hierarchy (view full)

Constructors

Properties

ballNormal: boolean = false

true if the normal object's edge is curved

ballObject: boolean = false

true if the 'primary' object's edge is curved

creator: string = ''

for debugging, unique code tells where this was generated

distance: number = NaN

distance between objects; negative = penetration

distanceTol_: number

distance tolerance is used to decide when bodies are touching.

force: number = NaN

amount of force applied at a contact point

impact1: Vector = Vector.ORIGIN

point of impact, in global coords

impact2: null | Vector = null

second impact point needed for Rope because the impact points are far apart. OPTIONAL point of impact on normalBody, in global coords

impulse: number = NaN

amount of impulse applied during collision

joint: boolean

whether this is a bilateral constraint which can both push and pull

normal: Vector = Vector.NORTH

normal pointing outward from normalObj, in world coords

normalBody: RigidBody

object corresponding to the normal (its edge defines the normal vector)

normalFixed: boolean

true = normal is constant

normal_dt: null | Vector = null

derivative of normal vector with respect to time

primaryBody: RigidBody

'primary' object whose corner or edge is colliding

radius1: number = NaN

radius of curvature at impact1, for primary body; negative means concave

radius2: number = NaN

radius of curvature at impact1, for normal body; negative means concave

theConnector_: Connector

Connector that generated this collision

velocityTol_: number

velocity tolerance used to determine if an object is in contact with another object. See ImpulseSim.getVelocityTol.

Methods

  • Whether close enough to the point when this Collision can be handled. The allowTiny parameter exists because of cases where a small distance collision cannot be backed-up in time to get near to the preferred target 'half gap' distance.

    Parameters

    • allowTiny: boolean

      regard as 'close enough' Collisions that have smaller distance than distance accuracy would normally allow

    Returns boolean

    true if close enough to the point when this Collision can be handled.

  • Returns the elasticity used when calculating collisions; a value of 1.0 means perfect elasticity where the kinetic energy after collision is the same as before (extremely bouncy), while a value of 0 means no elasticity (no bounce). A collision uses the lesser elasticity value of the two bodies involved.

    Returns number

    elasticity used when calculating collisions, a number from 0 to 1.

  • Returns the normal body involved in the collision, which defines the normal vector. The classic situation is that a vertex on the primary body is colliding into an edge on the normal body, but there are many variations on this.

    Returns RigidBody

    the normal body involved in the collision

  • Returns the relative normal velocity based on current velocity of the bodies. Negative velocity means the objects moving towards each other, positive velocity means they are moving apart.

    Returns number

    relative normal velocity between the two bodies at the point of contact.

  • Returns the primary body involved in the collision. The primary body does not define the normal. The classic situation is that a vertex on the primary body is colliding into an edge on the normal body, but there are many variations on this.

    Returns RigidBody

    the primary body involved in the collision

  • Returns the difference in velocity of the two impact points of the collision based on current velocity of the bodies.

    let V = velocity of center of mass (CM);
    let R = distance vector CM to contact point
    let w = angular velocity
    w x R = (0, 0, w) x (Rx, Ry, 0) = (-w Ry, w Rx, 0)
    velocity of corner = V + w x R = (Vx - w Ry, Vy + w Rx, 0)
    relative velocity = Vab = Va + wa x Ra - Vb - wb x Rb
    

    For curved edge we use the U vector (from center of mass to edge's circle center) instead of R vector (from center of mass to point of impact). Because what matters is not the motion of the individual point but instead the entire curved edge. Consider that for a ball with center of mass at center of the circle, rotation doesn't change the distance at all.

    Returns Vector

    the velocity vector of this collision

  • Returns vector from center of mass of primary body to either point of impact or to center of circular edge in world coords.

    Returns Vector

    vector from center of mass of primary body to either point of impact or to center of circular edge in world coords

  • Returns vector from center of mass of normal body to either point of impact or to center of circular edge in world coords. Uses the second impact point if appropriate.

    Returns Vector

    vector from center of mass of normal body to either point of impact or to center of circular edge, in world coords

  • Returns the relative normal velocity between the two collision points. Negative velocity means the objects are colliding, positive means they are separating.

    Returns number

    relative normal velocity between the two collision points, negative means colliding

  • Returns true if this Collision needs to be resolved, such as by applying an impulse to reverse the velocities of the objects. This remains true even after backing up in time.

    Returns boolean

    true if this Collision needs to be resolved

  • Stores the time when this collision was detected, stores the current distance and velocity as the detected distance and detected velocity, and estimates when the collision occurred.

    Parameters

    • time: number

      when this collision is detected

    Returns void

    Throws

    if the detected time has been previously set

  • Mark this Collision as one that needs handling because it is has caused the collision engine to backup in time in order to resolve this Collision. This is useful because after backing up in time, a Collision may no longer report itself as isColliding.

    Parameters

    • needsHandling: boolean

      true if this Collision needs to be resolved

    Returns void

  • Returns whether this collision could be the same as another collision. Often there are several collisions found at a single location by the various collision detection mechanisms, and this is used when deciding which collision of those to keep.

    Parameters

    Returns boolean

    true if the two collisions are possibly the same collision

  • Updates the information in the collision to reflect current position and velocity of bodies. Changes the impact point to be the nearest point between the bodies (as long as this point is reasonably close to the original impact point). Then update the normal, R vectors, etc.

    This is used when handling collisions because the collisions are found post-collision, but are handled pre-collision. Therefore, we need to update the information to correspond to the pre-collision arrangement of the bodies.

    Doing this fixes inaccurate collisions; for example, a ball that hits a wall at an angle would wrongly acquire spin if the collision were not updated to the current pre-collision information.

    Assumes that the bodies have been updated for their current location, by for example RigidBodySim.modifyObjects.

    Parameters

    • time: number

      the current simulation time

    Returns void

Generated using TypeDoc