Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angle constraints #837

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open

Angle constraints #837

wants to merge 12 commits into from

Conversation

liabru
Copy link
Owner

@liabru liabru commented Mar 11, 2020

angle-constraints

Work in progress, this feature and API is subject to change.

Features

  • builds on Matter.Constraint
  • distance or pin supported
  • angles for one or both constraint points
  • angle stiffness, angle-min and angle-max bounds
  • global-relative angle for world points
  • body-relative angle for body points

Usage

See the Angle Constraints example for usage. The new constraint properties are:

  • constraint.angleA the target angle at point A (body-relative or world-relative depending on usage) (default 0 or initial angle between points and x-axis)
  • constraint.angleAMin min bound, anti-clockwise relative to angleA (radians, default 0)
  • constraint.angleAMax max bound, clockwise relative to angleA (radians, default 0)
  • constraint.angleAStiffness the angle stiffness (0 to 1, default 1)
  • constraint.angleB...
  • constraint.render.angles boolean to render angles when using Matter.Render (default true)

Angles are either relative to the body, or to the world (x-axis), depending on what the constraint is connected to. For example:

  • if constraint.bodyA is set, then constraint.angleA is relative to the body angle
  • if constraint.pointA is set, then constraint.angleA is relative to the world

Requesting reviewers, testers and comments

If anybody has any time to help me test this update out further and feedback any issues and test cases, it would be greatly appreciated.

You can try out this feature by using the alpha build on this branch.

Known issues

  • chains of angle constraints have issues
  • some configurations can build up extra energy when moving around rapidly
    • possibly a mouse constraint issue only

Breaking changes

  • the original internal property constraint.angleA is now constraint.angleAPrev (same for B)

Changes

  • adds angle properties to Matter.Constraint objects
  • adds angle constraints example
  • adds angle constraint solving to Matter.Constraint module
  • adds angle constraint rendering to Matter.Render
  • adds Common.angleDiff, Common.clampAngle

@Prokos
Copy link

Prokos commented Apr 3, 2020

Awesome!!!

While trying this out I ran into a small problem, if I try to make a pin constraint (length=0, stiffness>0.1) constrained by angles, the debug renderer breaks in Render.constraints as it's unable to draw a line to end.x, end.y as end is never set.

@liabru
Copy link
Owner Author

liabru commented Dec 30, 2020

@Prokos good catch, I couldn't reproduce the issue as I'm not sure on the setup required for it but I've accounted for that

* master:
  added version targets for examples
  added support for example versioning in tests
  add support for > and >= operators in plugin version ranges
@CarstenHoyer
Copy link

Hi @liabru is this one dead? What is missing? This would be a killer feature.

@SollyBunny
Copy link

Gonna have to bump this. This allows for axels and pins which were previously missing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants