Transform Multiply - Documentation / Order of transformation


Dear Steve and Menno @stevebaer @menno

I am a bit confused about how Matrix Multiplication is implemented here:
thanks for the nice explanation of Menno in this post

My question is about the Order the transformation will be combined.
The Documentation claims for xform = A*B

The resulting Transform gives the same result as though you’d first apply A then B.

I think it is the other way round:
->The resulting Transform gives the same result as though you’d first apply B then A.

the following example uses a Translation M (Move) X+100, and a rotation R around the Y-Axis:

    protected override Result RunCommand(RhinoDoc doc, RunMode mode)

        ObjRef[] obj_refs;
        var rc = RhinoGet.GetMultipleObjects("Select points to move", false, ObjectType.Point, out obj_refs);
        if (rc != Result.Success || obj_refs == null)
            return rc;
        // Translate x+ 100
        Transform xFormMove = Transform.Translation(100, 0, 0);
        // rotate 30degree arround y-Axis
        Transform xFromRotY = Transform.Rotation(Math.PI / 6.0, new Vector3d(0, 1, 0), new Point3d(0, 0, 0));

        // combine
        Transform xForm_MxR = xFormMove * xFromRotY;
        Transform xForm_RxM = xFromRotY * xFormMove;
        // check * and Transform.Multiply
        Transform xForm_RxM_2 = Transform.Multiply(xFromRotY, xFormMove);

        foreach (var obj_ref in obj_refs)
            Guid newID_MxR;
            Guid newID_RxM;

            // move * Rotate -> color Red
            newID_MxR = doc.Objects.Transform(obj_ref, xForm_MxR,false);
            RhinoObject ptMxR = (new ObjRef(newID_MxR)).Object();
            ptMxR.Attributes.ColorSource = ObjectColorSource.ColorFromObject;
            ptMxR.Attributes.Name = "MxR";
            ptMxR.Attributes.ObjectColor = System.Drawing.Color.FromArgb(231, 0, 0);

            // Rotate * Move -> color green
            newID_RxM = doc.Objects.Transform(obj_ref, xForm_RxM, false);
            RhinoObject ptRxM = (new ObjRef(newID_RxM)).Object();
            ptRxM.Attributes.ColorSource = ObjectColorSource.ColorFromObject;
            ptRxM.Attributes.Name = "RxM";
            ptRxM.Attributes.ObjectColor = System.Drawing.Color.FromArgb(0, 231, 0);

            // compare operator vs Method
            newID_RxM = doc.Objects.Transform(obj_ref, xForm_RxM_2, false);
            RhinoObject ptRxM2 = (new ObjRef(newID_RxM)).Object();
            ptRxM2.Attributes.ColorSource = ObjectColorSource.ColorFromObject;
            ptRxM2.Attributes.Name = "RxM_2";
            ptRxM2.Attributes.ObjectColor = System.Drawing.Color.FromArgb(0, 0, 231);

        return Result.Success;

(Menno Deij - van Rijswijk) #2

You are correct (I think I made a mistake in the post you refer to)

TS = TS => Scale then Translate
ST = S
T => Translate then Scale

The order of multiplication is reversed in the order of application of transforms.


Thanks Menno
And please Steve, update the documentation. - Thanks


I think something is incorrect here as well.

Ah, OK, sorry … did not see Tom’s link

(Steve Baer) #5

I added an issue to our bugtracker to fix this