# Matrixs

Hi Ill try and explain what I’m trying to do.

Basically I have a custom modal that I have built. The modal has a position and rotation.

Each modal has a collection of parts. Each part has its own position and rotation and contains all the vertexs.

So to move the modal I have

`````` matrix = Matrix.CreateFromYawPitchRoll(_parent.Yaw, _parent.Pitch, 0f);
matrix *= Matrix.CreateWorld(_parent.Position, Vector3.Forward, Vector3.Up);
``````

Where _parent is the actual modal.

Then for each part I have

``````  matrixpart = Matrix.CreateFromYawPitchRoll(part.Yaw, part.Pitch, 0f);
matrixpart *= Matrix.CreateWorld(part.Pos, Vector3.Forward, Vector3.Up);
``````

My question is this Is there a way to combine these two matrixs? or would I have to do something like this

``````  matrix = Matrix.CreateFromYawPitchRoll(_parent.Yaw + part.Yaw, _parent.Pitch + part.Pitch, 0f);
matrix *= Matrix.CreateWorld(_parent.Position + part.Position, Vector3.Forward, Vector3.Up);
``````

Thanks for the help Matt

I don’t understand the question, as the 2 matrices have to be combined (order is important), in your case the part

matrixpart = Matrix.CreateFromYawPitchRoll(part.Yaw, part.Pitch, 0f);
matrixpart = Matrix.CreateWorld(part.Pos, Vector3.Forward, Vector3.Up);

The first line in overwritten by the second one so its result is never used.

Your write iv fixed the code. Must have accidentally deleted the * when making this topic.

If the child object has position and rotation relative to the parent, then you multiply the transformation matrix of the child with the transformation matrix of the parent to get the model transformation of the child. I can never remember which way around the multiply goes (parent * child, or child * parent), so I usually try each way and see which one works.

Thx that’s exactly what was hoping for. I’ll look and try getting it working.

Thought I was the only one