Transform.GetQuaternion() returns NaN values after rotation

Hi all,
I am modifying a gltf importer/exporter for Rhino and am trying to get the transformation of blocks so I can save it alongside geometries themselves. I am not sure what I am doing wrong, but everytime in a sample file if I have a geometry that turns 180 I would get a NaN values in

Transform.GetQuaternion().

Here’s my function -

Node createBlockNode(string name, Transform trans, int child = -1, ExtrasSHoP extras = null)
{
    Vector3d translation, diag;
    Transform rotation, orth;
    Quaternion quaternion = Quaternion.Identity;


    trans.DecomposeAffine(out translation, out rotation, out orth, out diag);
    rotation.GetQuaternion(out quaternion);
}

the quaternion would turn out to be something like:

 [
        6.123234E-17,
        "NaN",
        "NaN",
        "NaN"
]

Hi @Tim_Li,

Can you provide a simple way for me to reproduce this?

– Dale

Hi @dale, sorry for the delay as I found a workaround with .Net’s api. But to reproduce, you just have to make a block and turn it 180 degrees and try to call DecomposeAffine on the transformation and then call rotation.GetQuaternion() and the resulting quaternion would have NANs in it