I am trying to implement this paper:

http://www.cg.informatik.uni-mainz.de/f ... t-Rods.pdf

I have got the position based rod simulation framework implemented but I got stuck on the constraints.

In eq. 37 for the correction of

*q*there is

*qe_3*but I don't know how to implement this in terms of operations.

I am not sure what

*e_3*is. I know that the dash is quaternion conjugate (i.e. inverse). The bold

**is the world frame 3rd (z) basis vector, which is [0,0,1].**

*e_3*Thanks for your help!

EDIT: OK, earlier the paper states "The non-bold notation of

*p*denotes that the vector is embedded into a quaternion with vector part

*and scalar part 0."*

**p**So does

*e_3*simply equals quat[0, 0, 1, 0]?

Plus I am still not sure how to multiply the expression (the left side is Vec3f and the right is Quat4f)

Code: Select all

```
public static void ProjectStretchAndShearConstraint(ref Vector3 pA, ref Vector3 pB, ref Quaternion q, float wA, float wB, float wQ, float restLength, float kS)
{
Vector3 dir = pB - pA;
float len = Vector3.Magnitude(dir);
if (len <= EPSILON)
return;
float wSum = wA + wB + (4 * wQ * len * len);
if (wSum <= EPSILON)
return;
Vector3 d3 = q * Vector3.forward;
Vector3 dP = (1.0f / wSum) * (dir / len - d3);
pA += dP * wA * len * kS;
pB -= dP * wB * len * kS;
Vector4 dPQ = (1.0f / wSum) * (dir / len - d3) * // WHAT GOES HERE!?;
// q += dPQ * wQ * len * len;
}
```