Click here to Skip to main content
15,898,770 members

Comments by paulrm (Top 3 by date)

paulrm 17-Nov-14 5:53am View    
Thanks Andi,

I was aware the calculations were not commutative. I had determined the 1st and 3rd steps in the sequence and had just theorized the 2nd, but have not tried it yet. Your solution matches my theory.

I'll put it into practice after work today and see if it is in fact the solution I was looking for.

I am able to visualize the required steps, but I am not a math wizard and so the equations do not come easily to me.

Thanks again.
paulrm 16-Nov-14 19:00pm View    
I was pretty sure the above matrix would be close, but it does not work. The translation is correct, but the rotation is not.

Here's my effect.World line from the Draw function;

effect.World = (absoluteTransforms[mesh.ParentBone.Index] * rotation) * translation * camera.World;

Any help will be greatly appreciated.

paulrm 15-Nov-14 21:58pm View    
The 3 points are defined within the model and are transformed by the matrix given. They could be any 3 points from a mesh within the model. The plane is arbitrary. It can and will change.

I want to align the 3 axes, of an object with a base centered at Vector3.Zero, to the 3 axes of the plane.

The answer will probably be something like;

Matrix rotation = Matrix.CreateRotationX((float)Math.Acos(Vector3.Dot(plane.Normal, Vector3.Right))) * Matrix.CreateRotationY((float)Math.Acos(Vector3.Dot(plane.Normal, Vector3.Up))) * Matrix.CreateRotationZ((float)Math.Acos(Vector3.Dot(plane.Normal, Vector3.Forward)));