fisica
Class FContactResult

java.lang.Object
  extended by fisica.FContactResult

public class FContactResult
extends java.lang.Object

Represents the result of the contact between two bodies. Objects of this type are not created by the users. Contact results are passed to the user when they implement the contactResult(FContactResult){ } method in the applet:

 FWorld world;

 void setup() {
   Fisica.init(this);

   world = new FWorld();
   world.setEdges();

   // Create and add bodies to the world here
   // ...
 }

 void draw() {
   world.step();
   world.draw();
 }

 void contactResult(FContactResult result) {
   // Draw an ellipse where the contact took place and as big as the normal impulse of the contact
   ellipse(result.getX(), result.getY(), result.getNormalImpulse(), result.getNormalImpulse());

   // Trigger your sound here
   // ...
 }

 
To know if the contact is the beggining, the continuation or the end of a contact it is better to use the other methods contactStarted(FContact){ }, contactPersisted(FContact){ } and contactEnded(FContact){ }.

See Also:
FContact

Method Summary
 FBody getBody1()
          Returns the first body involved in the contact.
 FBody getBody2()
          Returns the second body involved in the contact.
 fisica.FContactID getId()
          Get the identifier of the contact.
 float getNormalImpulse()
          Returns the normal component of the impulse of the contact.
 float getNormalX()
          Returns the horizontal component of the contact normal.
 float getNormalY()
          Returns the vertical component of the contact normal.
 float getTangentImpulse()
          Returns the tangential component of the impulse of the contact.
 float getX()
          Returns the horizontal position of the contact point.
 float getY()
          Returns the vertical position of the contact point.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getBody1

public FBody getBody1()
Returns the first body involved in the contact.

Returns:
first of the bodies involved in the contact

getBody2

public FBody getBody2()
Returns the second body involved in the contact.

Returns:
second of the bodies involved in the contact

getX

public float getX()
Returns the horizontal position of the contact point.

Returns:
the horizontal position of the contact point in pixels
See Also:
getY()

getY

public float getY()
Returns the vertical position of the contact point.

Returns:
the vertical position of the contact point in pixels
See Also:
getX()

getNormalX

public float getNormalX()
Returns the horizontal component of the contact normal.

Returns:
the horizontal component of the contact normal
See Also:
getNormalY()

getNormalY

public float getNormalY()
Returns the vertical component of the contact normal.

Returns:
the vertical component of the contact normal
See Also:
getNormalX()

getNormalImpulse

public float getNormalImpulse()
Returns the normal component of the impulse of the contact. This gives an idea of the strength of the collision that took place. This represents the impulse necessary to avoid penetration of the bodies involved in the collision. The impluse is simply the force multiplied by the timestep. The result is returned in impulse units (kg * pixels / s).

Returns:
the normal component of the contact's impulse
See Also:
getTangentImpulse()

getTangentImpulse

public float getTangentImpulse()
Returns the tangential component of the impulse of the contact. This gives an idea of the strength of the friction between the bodies that took place. The impluse is simply the force multiplied by the timestep. The result is returned in impulse units (kg * pixels / s).

Returns:
the tangent component of the contact's impulse
See Also:
getNormalImpulse()

getId

public fisica.FContactID getId()
Get the identifier of the contact. This value is useful in order to uniquely identify a contact. A new contact ID is created whenever to bodies enter into contact at a given point. If the bodies slide against each other the contact ID is maintained even if the point of contact is modified due to the slide. As soon as the two bodies separate the contact is considered ended.

Returns:
a unique identifier representing the contact


processing library fisica by Ricard Marxer. (c) 2009-2013