This documentation is archived and is not being maintained.

Matrix Structure

Describes and manipulates a matrix.

Namespace:  Microsoft.WindowsMobile.DirectX
Assembly:  Microsoft.WindowsMobile.DirectX (in Microsoft.WindowsMobile.DirectX.dll)

public struct Matrix

This structure represents a 4 × 4 matrix of single-precision floating-point numbers. The fields of this structure are named with the row number first, then the column number.

In Microsoft Windows Mobile Direct3D, the M34 element of a projection matrix cannot be a negative number. If an application needs to use a negative value in this location, it should scale the entire projection matrix by –1 instead.

The following example shows how to use a Matrix structure.

// This code example is from the Direct3D Mobile Matrices Sample 
// in the .NET Compact Framework Samples in the SDK. 
private void SetupMatrices()
    // For the world matrix, rotate the object about the y-axis. 

    // Set up the rotation matrix to generate one full rotation (2*PI radians) 
    // every 1000 ms. To avoid the loss of precision inherent in very high 
    // floating-point numbers, the system time is modulated by the rotation 
    // period before conversion to a radian angle. 
    int iTime = Environment.TickCount % 1000;
    float fAngle = iTime * (2.0f * (float)Math.PI) / 1000.0f;
    device.Transform.World = Matrix.RotationY(fAngle);
    // Set up the view matrix. A view matrix can be defined given an eye point, 
    // a point to look at, and a direction indicating which way is up. Here, you set 
    // the eye five units back along the z-axis and up three units, look at the 
    // origin, and define "up" to be in the y-direction.
    device.Transform.View = Matrix.LookAtLH(new Vector3(0.0f, 3.0f, -5.0f), new Vector3(0.0f, 0.0f, 0.0f), new Vector3(0.0f, 1.0f, 0.0f));
    // For the projection matrix, set up a perspective transform (which 
    // transforms geometry from 3-D view space to 2-D viewport space, with 
    // a perspective divide making objects smaller in the distance). To build 
    // a perspective transform, you need the field of view (1/4 PI is common), 
    // the aspect ratio, and the near and far clipping planes (which define 
    // the distances at which geometry should no longer be rendered).
    device.Transform.Projection = Matrix.PerspectiveFovLH((float)Math.PI / 4, 1.0f, 1.0f, 100.0f);

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Compact Framework

Supported in: 3.5, 2.0