# Stacking transforms to apply one tranfromation to use on multiple entities

**Christopher VanOosterhout**

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.

0

## Comments

Francis RouleauJust 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.

Christopher VanOosterhoutFrancis, 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.

Thanks

Francis RouleauI 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 :

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

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

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

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

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

Please sign in to leave a comment.