Click or drag to resize
DigitalRuneContact Class
Describes a contact (or the closest points) of two objects.
Inheritance Hierarchy
SystemObject
  DigitalRune.Geometry.CollisionsContact

Namespace: DigitalRune.Geometry.Collisions
Assembly: DigitalRune.Geometry (in DigitalRune.Geometry.dll) Version: 1.18.0.0 (1.18.2.14427)
Syntax
public sealed class Contact : IRecyclable

The Contact type exposes the following members.

Methods
  NameDescription
Public methodStatic memberCreate
Creates an instance of the Contact class. (This method reuses a previously recycled instance or allocates a new instance if necessary.)
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodRecycle
Recycles this instance of the Contact class.
Public methodToString
Returns a String that represents the current Object.
(Overrides ObjectToString.)
Top
Properties
  NameDescription
Public propertyFeatureA
Gets or sets the index of the shape feature of object A that was hit.
Public propertyFeatureB
Gets or sets the index of the shape feature of object B that was hit.
Public propertyIsRayHit
Gets a value indicating whether this contact is a hit by a ray.
Public propertyLifetime
Gets or sets the lifetime of this contact (in seconds).
Public propertyNormal
Gets or sets the normalized contact normal (pointing from object A to object B; in world space).
Public propertyPenetrationDepth
Gets or sets the penetration depth.
Public propertyPosition
Gets or sets the contact position (in world space).
Public propertyPositionALocal
Gets or sets the contact position on object A in the local space of object A.
Public propertyPositionAWorld
Gets the contact position on object A (in world space).
Public propertyPositionBLocal
Gets or sets the contact position on object B in the local space of object B.
Public propertyPositionBWorld
Gets the contact position on object B (in world space).
Public propertySwapped
Gets a copy of the contact where the collision objects are swapped.
Public propertyUserData
Gets or sets the user data.
Top
Remarks

A Contact is the result of a collision query. Contacts are usually stored in a ContactSet. A Contact describes a single contact point (or closest-point pair), whereas a ContactSet contains all contacts between two objects. (The involved objects are called "object A" and "object B".)

A Contact includes 2 points: a point on object A (see PositionALocal or PositionAWorld) and a point on object B (see PositionBLocal or PositionBWorld). The property Position is a point that lies halfway between those two points.

There are 4 types of contacts:

  • Touching Contact: Object A and object B are touching at the surface. The PenetrationDepth is 0. The points on object A and object B are identical. Position, PositionAWorld, and PositionBWorld are identical.
  • Penetrating Contact: Object A and object B are penetrating each other. The PenetrationDepth is greater than 0. PositionAWorld, and PositionBWorld are different and describe the points on object A and B that have maximum penetration. Position lies halfway between these two points.
  • Closest points (separated objects): Object A and object B are separated. They are not in contact. This can be the result of a closest-point query (see GetClosestPoints(CollisionObject, CollisionObject)). Normal contact queries such as GetContacts(CollisionObject, CollisionObject) or the contact queries performed inside a CollisionDomain ignore separated objects!

    The PenetrationDepth is negative. The absolute value of PenetrationDepth indicates the distance between the object A and object B. (The "penetration depth" is the inverse of "separation distance".) PositionAWorld and PositionBWorld are the closest points between the two objects. Position lies halfway between the closest points.

    Closest-point query is a special type of collision query. At first this might look confusing: Why does a closest-point query return a Contact? The reason that contacts and closest points are represented by the same class is that the collision detection internally treats contacts and closest points the same way.

  • Ray Hit: Either object A or object B is a ray that hits the other object. The PenetrationDepth stores the distance from the ray origin to the contact position on the second object. The Normal describes the surface normal at the contact position.

    (Ray hits can easily be found by checking whether the property IsRayHit is set in a Contact.)

See Also