This project is read-only.


The Matrix3DEx library is a collection of extension and factory methods for the Matrix3D struct. It's available for Windows WinRT including Universal Apps, Silverlight and Windows Phone Silverlight. The Matrix3D struct represents a 4x4 matrix that is used in combination with the Matrix3DProjection to apply more complex semi-3D scenarios to any UIElement than are possible with the simple PlaneProjection. This makes it possible to apply arbitrary model transformation matrices and perspective matrices to Silverlight elements. So it supports affine and non-affine transformations.
The Matrix3D struct is very minimalistic and has only a few members. The Matrix3DEx library tries to compensate that with extension and factory methods for common transformation matrices that are easy to use like built in methods.

screenshot.jpg cubemania.jpg gogoracer.jpg


  • Factory methods (Matrix3DFactory class)
    • Translation, scaling and rotation around x, y, z or any defined axis
    • Perspective field of view and orthographic projection
    • Camera (look-at) with position, target and up vector
    • Support for left-handed and right-handed coordination systems
  • Extension methods
    • Calculation of the matrix' determinant
    • Matrix transpose
    • SwapHandedness to change from right-handed to left-handed coordination system and vice versa
    • Dump of the values row by row into a formatted string
  • Math helper methods (MathHelper class)
    • Angle conversion from degrees to radians and vice versa

Live samples

Samples that come with the Matrix3DEx source code in action:
The Basic Sample loads some photos asynchronously and randomizes the position vector of each one. The sample uses most of the Matrix3DEx features and has some Sliders and CheckBoxes to change the parameters. Uncheck the "Animate" CheckBox to disable the camera movement and click on an Image to select it. The translation, scaling and the rotation matrices of the selected element can be changed with the corresponding Sliders. You can move the camera, change the target and the "Field Of View" with the other Sliders or fix the camera target at the selected element.

Great games

Dan Birch of developed two great games using Matrix3DEx (see the screenshots above).
Cubemania is a great and highly addictive rigid body physics game.
Go Go Racer! is a nice 2.5D racing game.

Easy to use!

// Create transformations

// Translate by x = 5, y = 4, z = -10
var translate = Matrix3DFactory.CreateTranslation(5, 4, -10);         

// Rotate 30° around x-axis
var rotateX = Matrix3DFactory.CreateRotationX(MathHelper.ToRadians(30));

// Double the size on x-axis, invert y and don't change z
var scale = Matrix3DFactory.CreateScale(2, -1, 1);

// Left-handed camera at the position x = 0, y = 5, z = 0 that looks to the negative z direction (z = -1)
var lookAt = Matrix3DFactory.CreateLookAtLH(0, 5, 0, 0, 0, -1);

// Left-handed perspective projection with a 45° field of view, a near view plane at 1 and a far view plane at 4000
var aspectRatio = myCanvas.Width / myCanvas.Height;
var projection = Matrix3DFactory.CreatePerspectiveFieldOfViewLH(MathHelper.ToRadians(45), aspectRatio, 1, 4000);

// Viewport transformation
var viewport = Matrix3DFactory.CreateViewportTransformation(myCanvas.Width, myCanvas.Height);

// Combine transformations
var world = scale * rotateX * translate;
var viewProjection = Matrix3DFactory.CreateViewportProjection(world, lookAt, projection, viewport);

// Apply transformation to UIElement
myImageControl.Projection = new Matrix3DProjection { ProjectionMatrix = viewProjection };

// Trace final matrix
myTextBlock.Text = viewProjection.Dump();

Additional Information

Matrix3DEx 1.0 - When PlaneProjection is not enough announced this project and provides some further information.
Matrix of the Universe - Matrix3DEx now available for Universal Apps announced the WinRT Universal Apps support.

Support it


Flattr this


René Schule coder and coordinator of this project.

Last edited Sep 25, 2014 at 9:02 AM by teichgraf, version 44