How to join two bodies so that they keep a constant distance

Official forum for the Chipmunk2D Physics Library.
Post Reply
tanis
Posts: 1
Joined: Thu Jan 16, 2014 1:52 pm
Contact:

How to join two bodies so that they keep a constant distance

Post by tanis »

I would like to have two bodies that are joined like this:

Code: Select all

A
|
|
B
and body B should always be at the same distance from A and shouldn't rotate around a pivot. It should always straight down below A. How would you achieve that with Chipmunk?
LegoCylon
Posts: 29
Joined: Wed May 09, 2012 12:06 am
Contact:

Re: How to join two bodies so that they keep a constant dist

Post by LegoCylon »

A pin joint will maintain constant distance between two bodies. I'd suggest adding one between the centers of each body unless you want B to move up and down as A rotates.

However, this will not guarantee that B will always be below A. For instance, if the forces and velocities of each body do not match then it is likely that they will move out of alignment (although the pin joint will keep their distance constant). I can't think of any combination of existing constraints that is capable of keeping B directly below A. The simplest option would be to make bodies A and B into shapes 1 and 2 of body A (no constraints required since shapes never move relative to their body) and give that body an infinite moment of inertia to prevent torque from rotating it. If it's necessary to keep them as separate bodies then I think you may need to write your own constraint solver (see cpPinJoint.c for an example).
ranaraza
Posts: 1
Joined: Thu Apr 23, 2015 1:28 am
Contact:

Re: How to join two bodies so that they keep a constant dist

Post by ranaraza »

A pin joint will maintain constant distance between two bodies. I'd suggest adding one between the centers of each body unless you want B to move up and down as A rotates.
If you are looking for fast success in certkillerthen join today to 70-412 dumps find complete testking and pass passguide on first try. A person can pick www.hood.edu and University of Hawaii for its easiness.
Post Reply

Who is online

Users browsing this forum: No registered users and 11 guests