hAPI Fisica  0.1
The hAPI Fisica physics engine expands Richard Marxer's fisica for Processing. The engine wraps the jbox2d physics engine for use with the Haply Development kit and the Hapkit.
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
FContact Class Reference

Public Member Functions

FBody getBody1 ()
 
FBody getBody2 ()
 
float getX ()
 
float getY ()
 
float getVelocityX ()
 
float getVelocityY ()
 
float getNormalX ()
 
float getNormalY ()
 
float getSeparation ()
 
float getFriction ()
 
float getRestitution ()
 
FContactID getId ()
 
boolean contains (String n1, String n2)
 
boolean contains (FBody n1, FBody n2)
 
boolean contains (String n1)
 
boolean contains (FBody n1)
 

Protected Member Functions

 FContact (ContactPoint contactPoint)
 

Protected Attributes

FBody m_body1
 
FBody m_body2
 
Vec2 m_position
 
Vec2 m_velocity
 
Vec2 m_normal
 
float m_separation
 
float m_friction
 
float m_restitution
 
FContactID m_id
 

Detailed Description

Represents a contact between two bodies. Objects of this type are not created by the users. Contacts are passed to the user when they implement the

contactStarted(FContact){ }

,

contactPersisted(FContact){ }

and

contactEnded(FContact){ }

methods in the applet:

FWorld world;
void setup() {
world = new FWorld();
world.setEdges();
// Create and add bodies to the world here
// ...
}
void draw() {
world.step();
world.draw();
}
void contactStarted(FContact contact) {
// Draw in green an ellipse where the contact took place
fill(0, 170, 0);
ellipse(contact.getX(), contact.getY(), 20, 20);
}
void contactPersisted(FContact contact) {
// Draw in blue an ellipse where the contact took place
fill(0, 0, 170);
ellipse(contact.getX(), contact.getY(), 10, 10);
}
void contactStarted(FContact contact) {
// Draw in red an ellipse where the contact took place
fill(170, 0, 0);
ellipse(contact.getX(), result.getY(), 20, 20);
}

To know if the contact is the beggining, the continuation or the end of a contact it is better to use the other method

contactResult(FContactResult){ }

.

Contacts

See also
FContactResult

Member Function Documentation

◆ contains() [1/4]

boolean FContact.contains ( String  n1,
String  n2 
)

Returns true if the contact contains the two bodies. If one of the bodies does not have a name this function returns false.

Parameters
n1the name of one of the bodies
n2the name of another one of the bodies
Returns
true if the contact bodies have the names given by the parameters
See also
FBody::setName

◆ contains() [2/4]

boolean FContact.contains ( FBody  n1,
FBody  n2 
)

Returns true if the contact contains the two bodies.

Parameters
n1one of the bodies
n2another one of the bodies
Returns
true if the contact bodies are the ones given by the parameters

◆ contains() [3/4]

boolean FContact.contains ( String  n1)

Returns true if the contact contains the body.

Returns
true if one of the contact bodies has the name given by the parameters
See also
FBody::setName

◆ contains() [4/4]

boolean FContact.contains ( FBody  n1)

Returns true if the contact contains the body.

Returns
true if one of the contact bodies has the name given by the parameters

◆ getBody1()

FBody FContact.getBody1 ( )

Returns the first body involved in the contact.

Returns
first of the bodies involved in the contact

◆ getBody2()

FBody FContact.getBody2 ( )

Returns the second body involved in the contact.

Returns
second of the bodies involved in the contact

◆ getFriction()

float FContact.getFriction ( )

Get the friction coefficient of the contact. The friction determines the ratio of the reaction force tangent to a contact that the two bodies will recieve. Basically it can be seen as a coefficient that will control how the bodies get slown down when they slide against each other. This value depends on the friction coefficients of the two bodies involved in the contact.

Returns
a positive value. A value of 0 means no friction and thus the body will not be slown down if no other forces are applied

◆ getId()

FContactID FContact.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

◆ getNormalX()

float FContact.getNormalX ( )

Returns the horizontal component of the contact normal.

Returns
the horizontal component of the contact normal
See also
getNormalY

◆ getNormalY()

float FContact.getNormalY ( )

Returns the vertical component of the contact normal.

Returns
the vertical component of the contact normal
See also
getNormalX

◆ getRestitution()

float FContact.getRestitution ( )

Get the restitution coefficient of the contact. The restitution determines the ratio of the reaction force normal to a contact that the two bodies will recieve. Basically it can be seen as a coefficient that will control the strength with which the bodies bounce back from the collision. This value depends on the resititution coefficients of the two bodies involved in the contact.

Returns
a positive value. A value of 0 means no bounce after a collision, and a value of 1 means bounce with it's full speed from a collision

◆ getSeparation()

float FContact.getSeparation ( )

Get the separation between the bodies.

Returns
a positive value means that the bodies have space between them, negative values means that the bodies have penetrated each other

◆ getVelocityX()

float FContact.getVelocityX ( )

Returns the horizontal component of the contact velocity.

Returns
the horizontal component of the contact velocity
See also
getVelocityY

◆ getVelocityY()

float FContact.getVelocityY ( )

Returns the vertical component of the contact velocity.

Returns
the vertical component of the contact velocity
See also
getVelocityX

◆ getX()

float FContact.getX ( )

Returns the horizontal position of the contact point.

Returns
the horizontal position of the contact point in simulation world units
See also
getY

◆ getY()

float FContact.getY ( )

Returns the vertical position of the contact point.

Returns
the vertical position of the contact point in simulation world units
See also
getX

The documentation for this class was generated from the following file: