Page 1 of 1

Pivot Joint Anchor Placement

Posted: Fri Feb 26, 2016 5:38 am
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...

Re: Pivot Joint Anchor Placement

Posted: Fri Feb 26, 2016 10:28 am
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.