RhinoCommon Quaternions


(David Rutten) #1

So I’m very confused about Quaternions in RhinoCommon (or quite possibly in general). I figured that the following code would allow me to rotate one plane towards another by varying the parameter from 0.0 to 1.0, but I’m not getting the correct results at all. I don’t care about the translation aspect, we can assume that both planes have their origin at (0,0,0).

Clearly I cannot interpolate quaternions like I would regular numbers. What is the correct way?

Plane BlendPlane(Plane plane0, Plane plane1, double parameter)
{
  Quaternion q0 = Quaternion.Identity;
  Quaternion q1 = Quaternion.Rotation(plane0, plane1);
  Quaternion q2 = (q0 * (1 - parameter)) + (q1 * parameter);

  Transform transform = q2.MatrixForm();
  plane0.Transform(transform);
  return plane0;
}

#2

I’m struggling with the same rotation interpolation problem between two planes, is there any extra information on this?


(Dale Fugier) #3

Some like this algorithm:


#4

Thanks Dale! I used slerp and it works well. For people who need some standard implementation, I advise to use System.Numerics.Vectors,

https://msdn.microsoft.com/en-us/library/dn858218(v=vs.111).aspx

It has some nice features for Quaternion type


(David Rutten) #5

But single-precision only, so be careful with that.


#6

thx for bringing that up, will check if there are further consequences from that to our case, I suppose as long as precision errors don’t build up in a chain of transforms it should be fine for our situation. Would be nice to get some standard implementation in Rhinocommon though :slight_smile: