Hello,
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.
Best,
Amaury
visose
(Vicente Soler)
March 23, 2018, 12:26am
2
They are quaternions (euler would be 3 numbers). You can check my robots plugin: http://www.github.com/visose/robots
1 Like
I just recently heard about “Quaternion Rotation” from @Michael_Pryor - sounds fascinating:
More here:
I have to look into quaternions. But can anyone provide with a code example of how to use them?
For example rotating an object around a vector, and transforming an object from one plane to another. I know there are plugins that can handle quaternions (Falcon and Pufferfish has it) but I need to be able to code it myself (RhinoCommon quaternions ).
I tried a bit but the results doesn’t make sense to me… What I did was creating a vector from two box corners (see fig below) and created a transfor…
1 Like
visose
(Vicente Soler)
March 23, 2018, 1:14am
4
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;
}
4 Likes
Hi Vicente, have you seen these ones from Daniel?
Hi Rolf,
A little late to this quaternion party,
I’m not sure why you say you have to use quaternions, but not what you want to do with them - it seems a strange way round to start to me
They do certainly have their uses, but depending on the problem may not be the only or best solution.
Anyway, assuming this is something to do with rotation, to throw another example into the mix, I’ve included below a simple linear interpolation, and also something I did using Quaternions to inte…
1 Like
visose
(Vicente Soler)
March 23, 2018, 1:37am
6
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
1 Like
then I am sure you will love his QuaternionSpline.gh Obfuscation
1 Like
thanks a lot for your help, I will look at this carefully !!!
visose
(Vicente Soler)
March 23, 2018, 6:53pm
9
Very creative. I was learning a bit of JavaScript recently and my first thought was that I opened the minified version.
RIL
(Rolf)
March 24, 2018, 3:10am
10
Michael_Pryor:
QuaternionSpline.gh
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)
https://twitter.com/VergaraLautaro/status/977215144509034497
// Rolf
2 Likes
Thanks a lot, I had time to have a look to your code, it was very helpful !!! now I need to create the socket the send the rapid code !!!