Pivot Joint Anchor Placement

Official forum for the Chipmunk2D Physics Library.

Pivot Joint Anchor Placement

Postby PiMaker » Fri Feb 26, 2016 5:38 am

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...
Posts: 3
Joined: Wed Feb 24, 2016 11:57 am

Re: Pivot Joint Anchor Placement

Postby slembcke » Fri Feb 26, 2016 10:28 am

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/
User avatar
Site Admin
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Return to Chipmunk2D Physics

Who is online

Users browsing this forum: No registered users and 1 guest