Stacking transforms to apply one tranfromation to use on multiple entities

I am looking to do a forward kinematic chain. instead of applying a tranformation via entity.transfromBy(...) multiple times I would like to have a simple object that can track a stacking of transforms then apply one entity.transformBy(...). This is partially because I (probably incorrectly) believe each entity.transformBy(...) is recalculating the vertices thus causing time computation time, but ultimately it would be cleaner to have the standalone object that I can reuse as I will need to have a nested for loop to accomplish the forward kinematic. 




Date Votes
  • Just use the typical assembly/part transformation logic. Each matrix of object in the chain are considering their parent their world.

    using the basics truth as follow :

    - a transformation is a matrix

    - a matrix is only composable in a single way but decomposable in infinite way

    - matrix can be applied infinitely


    If you keep a list of matrix or tree of matrix applying them to each other will give you the final matrix.



  • Francis, Thank you for your response. Can you please provide your suggestion as a small code snippet. I can get the matrix from a transformation however I don't know how to manipulate the matrix. I understand that the transformation is a matrix but am unsure how to multiply the raw matrix to get another one within the devdept software.


  • I typically stay away from the devdept transformation. I usually go with the built in .NET matrix (System.Windows.Media.Media3D.Matrix3D)

    Once ready to display i simply convert the .net matrix to devdept tranformation with an extension :

     public static double[] ToEyeshotMatrix(this Matrix3D matrix)
         // this is to format a windows matrix to the proper format eyeshot uses
         return new[]

    Then when i have a matrix i just use the extention with for example

    // create a windows matrix

    var myMatrix = System.Windows.Media.Media3D.Matrix3D.Identity

    // apply some transformation to it


    // apply a dev dept transform to a mesh using the extension that convert the matrix to a double[] which is what the transform uses

    myMesh.TransformBy(new Transformation(myMatrix.ToEyeshotMatrix()));


    Now if you create an object class that is a tree node style which mean it contain itself and has access to both his child and his parent you can multiply matrices by using hierarchy. This is a just a quick example

     public class HierachyItem
         // matrix of the current object
         public System.Windows.Media.Media3D.Matrix3D Matrix { get; set; } = System.Windows.Media.Media3D.Matrix3D.Identity;

         // parent object
         public HierachyItem Parent { get; set; } = null;

         // children in that object
         public List<HierachyItem> Children { get; set; } = new List<HierachyItem>();

         // method to make object know who their parent is
         public void AddChildren(HierachyItem item)
             // set the parent to himself
             item.Parent = this;

             // add the item

         // property that compute the composition matrix (all matrix applied to each other hierachically)
         public System.Windows.Media.Media3D.Matrix3D ComposedMatrix
                 // if item has no parent his matrix is the root
                 if (Parent == null)
                     return Matrix;
                     // in .net matrix composition is Child x Parent
                     return Matrix * Parent.ComposedMatrix;

    Also if you just want to store in 1 item without hierarchy the composition you can simply store a list of matrix but the same concept apply. Child x Parent = current matrix so if the list is in order to apply you need to multiply the last by previous then the logic is a bit more complicated code wise

     public class Item
         // matrices that compose the final object location
         public List<System.Windows.Media.Media3D.Matrix3D> Matrices { get; set; } = new List<System.Windows.Media.Media3D.Matrix3D>();        

         // method that get the composed matrix of that object
         public System.Windows.Media.Media3D.Matrix3D GetComposedMatrix()
             // will keep the running total of matrix compute
             var composedMatrix = Matrices[0];

             // now first matrix is the parent so we need to skip it and second woult be it's child so you need to multiply index 1 by index 0
             // but then index 2 need to be multiply by (1 x 0) so we need a simple linq to skip and use a running total logic to do so
             Matrices.Skip(1).ForEach(m =>
                 composedMatrix = m * composedMatrix;

             return composedMatrix;

    here just throwing that extra thing. If you only have a eyeshot transformation of some kind here is an extention to convert a transform to a .net matrix

      private static Matrix3D ToWindowsFormatedMatrix(this devDept.Geometry.Transformation transform)
          var matrix = transform.MatrixAsVectorByColumn;
          return new Matrix3D(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5], matrix[6], matrix[7], matrix[8], matrix[9], matrix[10], matrix[11], matrix[12], matrix[13], matrix[14], matrix[15]);


  • Francis, Thank you for this. That was much more than I was thinking. This is very helpful.


Please sign in to leave a comment.

Didn't find what you were looking for?

New post