Question

I have 4 Boxes which are positioned like you can see in the following picture:

enter image description here

Now I want to turn them along the Y-Axis (left-handed, red line).

I use Managed DX an my first idea was to say for every box:

device.Transform.World = Matrix.RotationY(Geometry.DegreeToRadian(2)) * BoxPosition;

That works fine for the top and the bottom box. But the left and right box are turnling along there Y-Axis which is another one. Can someone help me how to turn them on the right Y-Axis (not the global Axis)? Position of the complete box in right-hand coordinates:

x = 12
y = 0
z = 0
Was it helpful?

Solution

It's just the other way round:

device.Transform.World =   BoxPositionWithinGroup
                         * Matrix.RotationY(Geometry.DegreeToRadian(2))
                         * GroupPositionInWorld;

Where GroupPositionInWorld would be Matrix.Translation(12, 0, 0) and BoxPositionWithinGroup describes a box' local position within the group (relative to the group position).

If you want to read more about DirectX and matrices, check out my blog post.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top