Transform Angles

I’m trying to get angles from a plane using either GetEulerZYZ, GetYawPitchRoll and GetQuaternion.
This is to set work planes to a robot (I’m using robotdk) and at this point I don’t know which method will work for me.
I’m stuck using any of those methods because I can’t extract any information from it.

Dim vTCPInfo = Transform.ChangeBasis(Plane.WorldXY, vTCPPlane)
                'vTCPPlane = {Origin=-185.778389695857,76.745590069475,46.8938003683418 XAxis=0.441596373625533,0.896311660205494,0.0402249994462356, YAxis=-0.00177615020492446,0.0457064664330206,-0.998953334353841, ZAxis=-0.897212064169463,0.441062724230781,0.0217757939670092}
                'vTCPInfo = {R0=(0.441596373625533,0.896311660205494,0.0402249994462356,11.3647928452118), R1=(-0.00177615020492446,0.0457064664330206,-0.998953334353841,43.0069781771568), R2=(-0.897212064169463,0.441062724230781,0.0217757939670092,-201.553381260991), R3=(0,0,0,1)}

Then any method fails:

vBolRes= vTCPInfo.GetEulerZYZ(alpha, beta, gamma) 
vBolRes= vTCPInfo.GetYawPitchRoll(yaw, pitch, roll)
vBolRes= vTCPInfo.GetQuaternion(quaternion)

Also tried with Transform.PlaneToPlane with the same results.
is this the correct way to use those functions, I’m missing something here?
Thanks in advance

Hi @Sérgio1,

Here is a test you can run in Rhino 8:

#! python 3
import Rhino

def Test():
    wp = Rhino.Geometry.Plane.WorldXY

    xaxis = Rhino.Geometry.Vector3d(0.441596373625533,0.896311660205494,0.0402249994462356)
    yaxis = Rhino.Geometry.Vector3d(-0.00177615020492446,0.0457064664330206,-0.998953334353841)
    zaxis = Rhino.Geometry.Vector3d(-0.897212064169463,0.441062724230781,0.0217757939670092)
    xaxis.Unitize()
    yaxis.Unitize()
    zaxis.Unitize()

    xform = Rhino.Geometry.Transform.Rotation(wp.XAxis, wp.YAxis, wp.ZAxis, xaxis, yaxis, zaxis)

    rc, a, b, c = xform.GetEulerZYZ()
    if rc:
        print("alpha: {}, beta: {}, gamma: {}".format(a, b, c))

    rc, a, b, c = xform.GetYawPitchRoll()
    if rc:
        print("yaw: {}, pitch: {}, roll: {}".format(a, b, c))

    rc, a = xform.GetQuaternion()
    if rc:
        print("quaternion: {}, ".format(a))

if __name__ == "__main__":
    Test()

Note:

  1. Transform.ChangeBasis creates a change-of-basis transformation, which is not the same as the rotation transformation.
  2. Transform.PlaneToPlane only creates a rotation transformation if the origins of the input planes are the world origin.

Hope this helps.

– Dale

Another example, this time with C#:

// #! csharp
using System;
using Rhino;
using Rhino.Geometry;

Plane wp = Plane.WorldXY;

Point3d origin = new Point3d(-185.778389695857,76.745590069475,46.8938003683418);
Vector3d xaxis = new Vector3d(0.441596373625533,0.896311660205494,0.0402249994462356);
Vector3d yaxis = new Vector3d(-0.00177615020492446,0.0457064664330206,-0.998953334353841);
Vector3d zaxis = new Vector3d(-0.897212064169463,0.441062724230781,0.0217757939670092);
xaxis.Unitize();
yaxis.Unitize();
zaxis.Unitize();

Plane tp = Rhino.Geometry.Plane.CreateFromFrame(origin, xaxis, yaxis);

Transform xform = Rhino.Geometry.Transform.PlaneToPlane(wp, tp);
if (xform.IsAffine)
{
    bool rc = xform.DecomposeAffine(out Rhino.Geometry.Transform linear, out Rhino.Geometry.Vector3d translation);
    if (rc)
    {
        Console.WriteLine("translation: {0}", translation);

        double a, b, c;
        rc = linear.GetEulerZYZ(out a, out b, out c);
        if (rc)
            Console.WriteLine("alpha: {0}, beta: {1}, gamma: {2}", a, b, c);

        rc = linear.GetYawPitchRoll(out a, out b, out c);
        if (rc)
            Console.WriteLine("yaw: {0}, pitch: {1}, roll: {2}", a, b, c);

        rc = linear.GetQuaternion(out Quaternion q);
        if (rc)
            Console.WriteLine("quaternion: {0}", q);
    }
}

– Dale