I am developing my own abb invert kinematic robotic plugin for a specific project.
However I need understand all the calculation to feed the rapid code.
Someone can quickly explain how to calculate the number needed (Please have a look to the red rectangle on the image below) acording to the oriented planes.
If you just want to convert planes to quaternions, this is the code I use:
public static double[] PlaneToQuaternion(Plane plane)
{
var q = Quaternion.Rotation(Plane.WorldXY, plane);
return new double[] { plane.OriginX, plane.OriginY, plane.OriginZ, q.A, q.B, q.C, q.D };
}
Or you want to interpolate 3d rotations? That’s more tricky and theres no “best” way, but a usual way is using axis angle, this is the code I use:
public Plane CartesianLerp(Plane a, Plane b, double t, double min, double max)
{
t = (t - min) / (max - min);
if (double.IsNaN(t)) t = 0;
var newOrigin = a.Origin * (1 - t) + b.Origin * t;
Quaternion q = Quaternion.Rotation(a, b);
q.GetRotation(out var angle, out var axis);
angle = (angle > PI) ? angle - 2 * PI : angle;
a.Rotate(t * angle, axis, a.Origin);
a.Origin = newOrigin;
return a;
}
Not that one, but an older one, which I reference in the github repository:
/// <summary>
/// Quaternion interpolation based on: http://www.grasshopper3d.com/group/lobster/forum/topics/lobster-reloaded
/// </summary>
Slight advantage of my code is a bit less newing and follows c sharp conventions rather than Daniel’s weird pascal case on parameters and local variables
Here’s a very special application where quaternions can help - Avoid Gimbal Lock or you are going to Burn! (you are still going to get smoked, but anyway)