Extracting ABC angles from Plane (Yaw Pitch Roll)

Hello,

I am having trouble extracting the yaw pitch and roll from a plane. I have a c# function that does the opposite: takes in abc values and produces a plane out of them:

public Rhino.Geometry.Plane calculatePlaneFromPos(string encodedPosition)
    {

        E6Pos position = new E6Pos(encodedPosition);
        Point3d tempPoint = new Point3d(position.xValue, position.yValue, position.zValue);
        Plane tempPlane = new Plane(tempPoint, new Vector3d(0, 0, 1));
        Transform rotationZ = Transform.Rotation(Rhino.RhinoMath.ToRadians(position.aValue), new Vector3d(0, 0, 1), tempPoint);
        tempPlane.Transform(rotationZ);
        Transform rotationY = Transform.Rotation(Rhino.RhinoMath.ToRadians(position.bValue), tempPlane.YAxis, tempPoint);
        tempPlane.Transform(rotationY);
        Transform rotationX = Transform.Rotation(Rhino.RhinoMath.ToRadians(position.cValue), tempPlane.XAxis, tempPoint);
        tempPlane.Transform(rotationX);
        return tempPlane;
    }

Now I need a function that does the opposite, takes in a plane and spits out XYZ and ABCs.
As background information, I am working on a software that interacts with a KUKA robot, and the datatype used involves having XYZ and ABC to define an endpoint for the robot arm to move to.

“In kuka, rotations are done in order A > B > C where
A is rotation about Z
B is rotation about Y
C is rotation about X”

Something similar has been asked here, but the solution provided does not work for my case.

Any suggestions?

Thanks!

See attached (and modify it at will)

Vector_ProjToPlane_V1.gh (11.0 KB)

First off thanks for the example. However I am having trouble understanding your file, could you complete it with another component/function that takes the angle values and recreates the plane? I think seeing the full loop would be didactically beneficial.

I went ahead and tested your definition with Pufferfish’s “Rotate Plane Euler” Component and it looks like the angles it spits out are incorrect. I cannot recreate the original plane by applying the transformation.

You mean that you want the “inverse” of that? (Note: Thread says: extract angles … NOT make plane from angles).

Vector_ProjToPlane_V1A.gh (116.1 KB)

I.E.: given a coordinate system and the 3 angles (as shown) make the plane (IF the angles are correct, that is).

BTW: Incorrect angles? Most unlikely: besides is so easy to see what’s happening (unless Rhino’s Vector3d.VectorAngle Method does bananas [not in a million years]).

BTW: Added some proof (But can The Lord be wrong? [not in a million years]) on that “incorrect” angle matter (unless we are talking about “other” angles).

Vector_ProjToPlane_V1B.gh (122.2 KB)

Thanks Lord! (or Vader?) these definitions really helped me grasp what I needed to do. The reason I thought the angles were wrong was because I needed to calculate my angles a bit differently (I asked the wrong question), but either way you sent me in the right direction. Ended up writing an algorithm based on the code here: http://javakuka.com/xyzabc/

Keep in mind that the inverse thingy (a CS system + the 3 (I do hope correct) angles => find the Z plane dir) is a classic 3 equations with 3 unknown values case.

double C1 = cos(angle1) ^2 = dx^2 + dy^2;
double C2 = cos(angle2) ^2 = dy^2 + dz^2;
double C3 = cos(angle3) ^2 = dx^2 + dz^2;

Easy (or nightmare) depending on Karma and other mysterious factors. But I do have C# stuff that does that [Matrices, Determinants etc etc] > notify if you need a freaky example - for instance for this case.