Pivot Joint Anchor Placement

Official forum for the Chipmunk2D Physics Library.
Post Reply
PiMaker
Posts: 3
Joined: Wed Feb 24, 2016 11:57 am
Contact:

Pivot Joint Anchor Placement

Post by PiMaker »

Imagine a rectangle with the dimensions w400 h100. It's attached to body is at x100 y100. I also have a circle with position x0 y0 and a radius of 30. How can I attach this wheel in a, you know, rotatable way to the right, bottom corner of the rectangle.

I generally think a Pivot Joint would be the correct solution for that (it's also one of the few joints that's supported in the golang port which I'm using btw). But what is the correct setup for the anchors to locate the wheel at the exact corner?

I've tried setting relative and world coordinates but it always leads to really weird results...
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Pivot Joint Anchor Placement

Post by slembcke »

In the vanilla C version, there are two ways to make a pivot joint. The first takes a global coordinate meaning that the objects already have to be carefully placed relative to each other to initialize the anchors local to each body. The second allows you to set the two local anchors explicitly. The catch is that if the two anchors don't line up, then the joint will jerk together as soon as it's added to the simulation.

For the latter 2 argument version version, you would use (0, 0) to center the pivot on the circle, and (100 - 400/2, 100 - 100/2) for one of the rectangle corners at least.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Post Reply

Who is online

Users browsing this forum: No registered users and 11 guests