# How do I represent a MD5-mesh bone (quaternion orientation)

Going off this link about the MD5Mesh file format, I see a bone is represented as:

"[boneName]"   [parentIndex] ( [xPos] [yPos] [zPos] ) ( [xOrient] [yOrient] [zOrient] )


Since xOrient,yOrient,zOrient make up an orientation quaternion and not a vector, I don't know how to illustrate them. I'm still trying to get a grasp of bones and mesh manipulation.

How is the following represented in file?:

• Two bones of a simple stick figure (origin as "a" & left(or right) leg as "b")
• groin of model is at origin with the head in the positive y-axis direction
• arm wing span goes across x-axis
• leg is facing down and 2 unit out on the x-axis from the origin

The three imaginary components of the quaternion form the axis of rotation, and the real component

wOrient = sqrt(1f - xOrient*xOrient - yOrient*yOrient - zOrient*zOrient)


is the cosine of half the angle of rotation about that axis. So you can translate this into an angle-axis form if you find that easier to reason about:

axis = normalize(xOrient, yOrient, zOrient)
angle = acos(wOrient) * 2.0


Here are some particular Quaternion values you might see:

 x     y     z     w     Interpretation

0     0     0     1     no rotation

0.26   0     0    0.97    30 degree rotation on x+ axis
0.50   0     0    0.87    60 degree rotation on x+ axis
0.71   0     0    0.71    90 degree rotation on x+ axis
0.87   0     0    0.50   120 degree rotation on x+ axis
0.97   0     0    0.26   150 degree rotation on x+ axis

1     0     0     0     180 degree rotation on x+ axis
0     1     0     0     180 degree rotation on y+ axis
0     0     1     0     180 degree rotation on z+ axis

-1     0     0     0     180 degree rotation on x- axis (or -180 on x+ axis)

0.71  0.71   0     0     180 degree rotation about the line y = x

• So the thing that confuses me is it represents a rotation and looking at a character model I see: "origin" -1 ( -0.000000 0.001643 -0.000604 ) ( -0.707107 -0.000242 -0.707107 ) // . Being the starting bone, how do I get it vector? Is there an assumed starting vector that the initial quaternion changes? Mar 6 '18 at 14:04
• Although we often draw bones with arrows, a bone's orientation is more than just a vector: it's a basis, consisting of a "longitudinal/forward/along" direction and a perpendicular "ventral/dorsal" direction, and a right-left direction perpendicular to the other two. The quaternion is transforming this basis from the initial identity orientation (local x+ pointing along world x+, local y+ pointing along world y+, local z+ pointing along world z+). The details for what that means for your character depends on the coordinate system conventions you're using. Mar 6 '18 at 18:00
• I'm getting a better idea, but I think this is just leading to a bigger question I'll need ask in another thread. The challenge I'm having is understanding how to illustrate a skeleton in it's initial state. Mar 7 '18 at 4:15
• hopefully my question: [Are there “default” vectors when dealing with bones represented by quaternion orientation] is a more refined question to help me understand the MD5 mesh format. Hopefully you can help me there. Mar 7 '18 at 5:20