Method FramesFromWorldAnchor
- Namespace
- Box3D
- Assembly
- Box3D.NET.dll
FramesFromWorldAnchor(Body, Body, Vector3, Vector3)
Builds a matched pair of joint frames from a world-space anchor and axis.
public static (JointFrame FrameA, JointFrame FrameB) FramesFromWorldAnchor(Body bodyA, Body bodyB, Vector3 worldAnchor, Vector3 worldAxis)Parameters
bodyABody-
The first body.
bodyBBody-
The second body.
worldAnchorVector3-
The point both bodies are pinned to, in world space.
worldAxisVector3-
The axis the joint acts about, in world space. It is placed on the frames' z axis, which is what revolute, spherical and parallel joints turn about. Prismatic and wheel joints use the frames' x axis, so pass the sliding direction as the axis and the joint will slide along it.
Returns
- (JointFrame FrameA, JointFrame FrameB)
-
The frames, expressed in each body's local space.
Examples
// A door hinged on its left edge, turning about the world up axis.
var (frameA, frameB) = Joint.FramesFromWorldAnchor(
frame, door, hingePoint, Vector3.UnitY);
world.CreateRevoluteJoint(new RevoluteJointDefinition
{
Base = JointDefinition.Connect(frame, door, frameA, frameB),
});
Remarks
This is the calculation people otherwise get wrong: the two frames must describe the same world pose from each body's point of view, or the joint starts out already violated and snaps on the first step.