Windows Graphics Transformations

2‑D Transformations

The Windows graphics stack provides a set of 2‑D transformation APIs that can be used with Matrix3x2F, CanvasDrawingSession, and GDI+.

Matrix3x2F m = Matrix3x2F.Identity;
m = Matrix3x2F.Rotation(angle) * Matrix3x2F.Scale(sx, sy) * Matrix3x2F.Translation(tx, ty);

3‑D Transformations

For 3‑D graphics, Windows provides Matrix4x4 and the Direct2D/Direct3D integration.

Matrix4x4 view = Matrix4x4.CreateLookAt(cameraPos, target, up);
Matrix4x4 proj = Matrix4x4.CreatePerspectiveFieldOfView(fov, aspect, nearZ, farZ);

Live Sample: Interactive Transformation Demo

API Reference

Class / Struct Member Description
Matrix3x2F Translation Creates a matrix that translates points.
Matrix3x2F Scale Creates a scaling matrix.
Matrix3x2F Rotation Creates a rotation matrix.
Matrix4x4 CreateLookAt Creates a view matrix for a camera.
Matrix4x4 CreatePerspectiveFieldOfView Creates a perspective projection matrix.