EPhysics Constraint

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files
- Examples

Typedefs | Functions
EPhysics Constraint
EPhysics

Constraints can be used to limit bodies movements, between bodies or between bodies and the world. More...

## Typedefs
typedef struct _EPhysics_Constraint | EPhysics_Constraint
| Constraint handle, used to limit bodies movements. More...

## Functions
EAPI EPhysics_Constraint * | ephysics_constraint_linked_add (EPhysics_Body *body1, EPhysics_Body *body2)
| Create a new constraint between 2 bodies(Point to Point constraint). More...
EAPI void | ephysics_constraint_anchor_set (EPhysics_Constraint *constraint, Evas_Coord anchor_b1_x, Evas_Coord anchor_b1_y, Evas_Coord anchor_b1_z, Evas_Coord anchor_b2_x, Evas_Coord anchor_b2_y, Evas_Coord anchor_b2_z)
| Change the constraints anchors values on both constrained bodies. More...
EAPI void | ephysics_constraint_anchor_get (const EPhysics_Constraint *constraint, Evas_Coord *anchor_b1_x, Evas_Coord *anchor_b1_y, Evas_Coord *anchor_b1_z, Evas_Coord *anchor_b2_x, Evas_Coord *anchor_b2_y, Evas_Coord *anchor_b2_z)
| Get the constraints anchors values on both constrained bodies. More...
EAPI EPhysics_Constraint * | ephysics_constraint_add (EPhysics_Body *body)
| Create a new constraint. More...
EAPI void | ephysics_constraint_linear_limit_set (EPhysics_Constraint *constraint, Evas_Coord lower_x, Evas_Coord upper_x, Evas_Coord lower_y, Evas_Coord upper_y, Evas_Coord lower_z, Evas_Coord upper_z)
| Define the linear moving limits of a `constraint`. More...
EAPI void | ephysics_constraint_linear_limit_get (const EPhysics_Constraint *constraint, Evas_Coord *lower_x, Evas_Coord *upper_x, Evas_Coord *lower_y, Evas_Coord *upper_y, Evas_Coord *lower_z, Evas_Coord *upper_z)
| Get the linear moving limits of a `constraint`. More...
EAPI void | ephysics_constraint_angular_limit_set (EPhysics_Constraint *constraint, double counter_clock_x, double clock_wise_x, double counter_clock_y, double clock_wise_y, double counter_clock_z, double clock_wise_z)
| Set the angular moving limits of a `constraint`. More...
EAPI void | ephysics_constraint_angular_limit_get (const EPhysics_Constraint *constraint, double *counter_clock_x, double *clock_wise_x, double *counter_clock_y, double *clock_wise_y, double *counter_clock_z, double *clock_wise_z)
| Get the angular moving limits of a `constraint`. More...
EAPI void | ephysics_constraint_del (EPhysics_Constraint *constraint)
| Deletes a physics constraint. More...

## Detailed Description

Constraints can be used to limit bodies movements, between bodies or between bodies and the world.

Constraints can limit movement angle, translation, or work like a motor.

Constraints can be created with ephysics_constraint_linked_add() or ephysics_constraint_add() and removed with ephysics_constraint_del(). Can be applied between two bodies or between a body and the world.

## Typedef Documentation

typedef struct _EPhysics_Constraint EPhysics_Constraint

Constraint handle, used to limit bodies movements.

Created with ephysics_constraint_linked_add() or ephysics_constraint_add() and deleted with ephysics_constraint_del().

## Function Documentation

EAPI EPhysics_Constraint* ephysics_constraint_linked_add | ( | EPhysics_Body * | body1,
|  | EPhysics_Body * | body2
| ) |  |

Create a new constraint between 2 bodies(Point to Point constraint).

The constraint will join two bodies(`body1` and `body2`) with angular and linear movements limited by calling ephysics_constraint_linear_limit_set() and ephysics_constraint_angular_limit_set(). Anchors values can be defined with ephysics_constraint_anchor_set().

Parameters

  body1 | The first body to apply the constraint.
  body2 | The second body to apply the constraint.

Returns
  A new linked(joining 2 bodies) constraint or `NULL`, on errors.

See also
  ephysics_constraint_del().

Examples:
  test_constraint.c.

EAPI void ephysics_constraint_anchor_set | ( | EPhysics_Constraint * | constraint,
|  | Evas_Coord | anchor_b1_x,
|  | Evas_Coord | anchor_b1_y,
|  | Evas_Coord | anchor_b1_z,
|  | Evas_Coord | anchor_b2_x,
|  | Evas_Coord | anchor_b2_y,
|  | Evas_Coord | anchor_b2_z
| ) |  |

Change the constraints anchors values on both constrained bodies.

Note
  By default the anchors are in the middle of a body, if a body of 20, 20 is positioned at (10, 10) then its anchor is set to (20, 20).
  There`s no need to inform `anchor_b2_x`, `anchor_b2_y` and `anchor_b2_z` if the constraint has been created using ephysics_constraint_add().

Parameters

  constraint | The constraint to be set.
  anchor_b1_x | The first body X anchor.
  anchor_b1_y | The first body Y anchor.
  anchor_b1_z | The first body Z anchor.
  anchor_b2_x | The second body X anchor.
  anchor_b2_y | The second body Y anchor.
  anchor_b2_z | The second body Z anchor.

See also
  ephysics_constraint_anchor_get().
  ephysics_constraint_linked_add().

Examples:
  test_constraint.c.

EAPI void ephysics_constraint_anchor_get | ( | const EPhysics_Constraint * | constraint,
|  | Evas_Coord * | anchor_b1_x,
|  | Evas_Coord * | anchor_b1_y,
|  | Evas_Coord * | anchor_b1_z,
|  | Evas_Coord * | anchor_b2_x,
|  | Evas_Coord * | anchor_b2_y,
|  | Evas_Coord * | anchor_b2_z
| ) |  |

Get the constraints anchors values on both constrained bodies.

Parameters

  constraint | The constraint to get anchor values from.
  anchor_b1_x | Pointer to an Evas_Coord in which to store the first body X anchor value.
  anchor_b1_y | Pointer to an Evas_Coord in which to store the first body Y anchor value.
  anchor_b1_z | Pointer to an Evas_Coord in which to store the first body Z anchor value.
  anchor_b2_x | Pointer to an Evas_Coord in which to store the second body X anchor value.
  anchor_b2_y | Pointer to an Evas_Coord in which to store the second body Y anchor value.
  anchor_b2_z | Pointer to an Evas_Coord in which to store the second body Z anchor value.

See also
  ephysics_constraint_anchor_set().
  ephysics_constraint_linked_add().

EAPI EPhysics_Constraint* ephysics_constraint_add | ( | EPhysics_Body * | body | ) |

Create a new constraint.

The constraint will limit the linear and angular moving of a body. This simple constraint is designated to constraint a single body.

Parameters

  body | The body to apply the constraint.

See also
  ephysics_constraint_linear_limit_set() for linear moving limit configuration.
  ephysics_constraint_angular_limit_set() for angular moving limit configuration.

Returns
  A new constraint or `NULL` on erros.

See also
  ephysics_constraint_del().

Examples:
  test_slider.c.

EAPI void ephysics_constraint_linear_limit_set | ( | EPhysics_Constraint * | constraint,
|  | Evas_Coord | lower_x,
|  | Evas_Coord | upper_x,
|  | Evas_Coord | lower_y,
|  | Evas_Coord | upper_y,
|  | Evas_Coord | lower_z,
|  | Evas_Coord | upper_z
| ) |  |

Define the linear moving limits of a `constraint`.

The linear limits are defined from the body's position on. The user will want to limit the movements on X, Y and Z axis where lower == upper axis will be locked, lower > upper axis is free, lower < upper axis is limited to the range.

The unit for every limits are defined on Evas coordinates.

Parameters

  constraint | The constraint to be set.
  lower_x | The lower linear moving limit on X axis.
  upper_x | The upper linear moving limit on X axis.
  lower_y | The lower linear moving limit on Y axis.
  upper_y | The upper linear moving limit on Y axis.
  lower_z | The lower linear moving limit on Z axis.
  upper_z | The upper linear moving limit on Z axis.

See also
  ephysics_constraint_linear_limit_get()

Examples:
  test_slider.c.

EAPI void ephysics_constraint_linear_limit_get | ( | const EPhysics_Constraint * | constraint,
|  | Evas_Coord * | lower_x,
|  | Evas_Coord * | upper_x,
|  | Evas_Coord * | lower_y,
|  | Evas_Coord * | upper_y,
|  | Evas_Coord * | lower_z,
|  | Evas_Coord * | upper_z
| ) |  |

Get the linear moving limits of a `constraint`.

Parameters

  constraint | The constraint to get linear limits from.
  lower_x | Pointer to set with the lower limit to the X axis.
  upper_x | Pointer to set with the upper limit to the X axis.
  lower_y | Pointer to set with the lower limit to the Y axis.
  upper_y | Pointer to set with the upper limit to the Y axis.
  lower_z | Pointer to set with the lower limit to the Z axis.
  upper_z | Pointer to set with the upper limit to the Z axis.

See also
  ephysics_constraint_linear_limit_set()

EAPI void ephysics_constraint_angular_limit_set | ( | EPhysics_Constraint * | constraint,
|  | double | counter_clock_x,
|  | double | clock_wise_x,
|  | double | counter_clock_y,
|  | double | clock_wise_y,
|  | double | counter_clock_z,
|  | double | clock_wise_z
| ) |  |

Set the angular moving limits of a `constraint`.

The angular moving limits is defined in degrees and will limit the moving on Z axis - counter clockwise and clockwise directions.

Parameters

  constraint | The constraint to be set.
  counter_clock_x | Amount of degrees from 0.0 to 360.0 to limit counter clockwise rotation on X axis.
  clock_wise_x | Amount of degrees from 0.0 to 360.0 to limit clockwise rotation on X axis.
  counter_clock_y | Amount of degrees from 0.0 to 360.0 to limit counter clockwise rotation o Y axis.
  clock_wise_y | Amount of degrees from 0.0 to 360.0 to limit clockwise rotation on Y axis.
  counter_clock_z | Amount of degrees from 0.0 to 360.0 to limit counter clockwise rotation on Z axis.
  clock_wise_z | Amount of degrees from 0.0 to 360.0 to limit clockwise rotation on Z axis.

See also
  ephysics_constraint_angular_limit_get()

Examples:
  test_slider.c.

EAPI void ephysics_constraint_angular_limit_get | ( | const EPhysics_Constraint * | constraint,
|  | double * | counter_clock_x,
|  | double * | clock_wise_x,
|  | double * | counter_clock_y,
|  | double * | clock_wise_y,
|  | double * | counter_clock_z,
|  | double * | clock_wise_z
| ) |  |

Get the angular moving limits of a `constraint`.

Parameters

  constraint | The constraint to get the angular limits from.
  counter_clock_x | Pointer to set with the counter clockwise limmit degrees on X axis.
  clock_wise_x | Pointer to set with the clockwise limit degrees on X axis.
  counter_clock_y | Pointer to set with the counter clockwise limit degrees on Y axis.
  clock_wise_y | Pointer to set with the clockwise limit degrees on Y axis.
  counter_clock_z | Pointer to set with the counter clockwise limit degrees on Z axis.
  clock_wise_z | Pointer to set with the clockwise limit degrees on Z axis.

See also
  ephysics_constraint_angular_limit_set()

EAPI void ephysics_constraint_del | ( | EPhysics_Constraint * | constraint | ) |

Deletes a physics constraint.

Parameters

  constraint | The constraint to be deleted.

See also
  ephysics_constraint_linked_add() for more details.
  ephysics_constraint_slider_add() for more details.