# How do I calculate the new Quaternions from translated points?

The code below is for a rag-doll using Verlet method, I have the correct points (or joints) positions, I just need the correct Quaternions, otherwise the resulting model looks like in the picture, I'm constraining the body to the bind pose on purpose for testing purposes.

Based on the two points, their position and quaternion, what will the new Quaternion be for each translated point?

struct Point
{
XMVECTOR position = { 0,0,0 };
XMVECTOR quaternion = { 0,0,0,-1 };
};

Point p1;
Point p2;

p1.position += { 0.0f,0.3f, 0.1f };
p2.position += { -1.0,0.3f,0.1f }; • I think in order to answer this, we'd need to know the expected orientations of each bone (eg. "the thigh bone's z+ axis points toward the knee and its y+ axis points forward"). For some situations you might need more than two points to decide the orientation of the bone — for instance, to pick the forward direction of the thigh we might want to know which way the shin is pointing — otherwise we might introduce an unnatural twist at the knee. – DMGregory Sep 15 '17 at 11:19
• Most of the joints in the bindpose have a quaternion of ( 0,0,0,-1), I construct the matrix and send it to the shaders for skinned animations, the model animates perfectly. But when I try to apply ragdoll the joint positions are ok, its the quaternions that are not ok , I do not know how to fix the quaternions after translating two points at a time. – Surface Sep 15 '17 at 18:33
• Quaternions don't do translation - they're for rotation only. – Maximus Minimus Apr 15 '19 at 13:18

void movePosxAxis(const glm::vec3 &n_pos) { placement.m_pos += n_pos * placement.m_orient; }

• The description of what the components of the quaternion represent is not correct. The three imaginary components represent the axis of rotation, scaled by the sine of half the angle of rotation. The real component is the cosine of half the angle of rotation. So quaternions representing 180 degrees of pitch, yaw, and roll would be (1,0,0,0), (0,1,0,0), and (0,0,1,0) respectively, and "no rotation" would be (0,0,0,1). A 180 degree rotation about a diagonal axis running 45 degrees between the x and y axes would be (1/sqrt(2),1/sqrt(2),0,0) – DMGregory Sep 15 '17 at 11:13