Click or drag to resize
DigitalRuneXNA Framework Support

DigitalRune Mathematics contains a version that supports the Microsoft XNA Framework (see also Files, Folders and Dependencies). This section explains XNA-specific issues.

Differences

Both, DigitalRune Mathematics and the Microsoft XNA Framework use a right-handed coordinate system. But vectors, matrices, and quaternions are used differently:

DigitalRune Mathematics

Microsoft XNA Framework

Coordinate system

right-handed

right-handed

Vector notation

column vectors

row vectors

Matrix notation

A matrix in DigitalRune Mathematics is the transpose of the matrix in XNA.

A matrix in XNA is the transpose of the matrix in DigitalRune Mathematics.

Matrix multiplication

A coordinate vector is transformed by using pre-multiplication (also known as multiplication on the left): v' = M · v

Transformations are concatenated by using pre-multiplication: M12 = M2 · M1. (Order is from right to left, M1 is applied before M2.)

A coordinate vector is transformed by using post-multiplication (also known as multiplication on the right): v' = v · M

Transformations are concatenated by using post-multiplication: M12 = M1 · M2. (Order is from left to right, M1 is applied before M2. The matrices are transposed.)

Quaternion notation

(w, x, y, z)

(x, y, z, w)

Quaternion multiplication

Quaternions are concatenated using the following order: q12 = q2 · q1. (Order is from right to left, q1 is applied before q2.)

Quaternions are concatenated using the following order: q12 = q2 · q1. (Order is from right to left, q1 is applied before q2.)

The matrix, vector and quaternion types contain methods to convert from or to the equivalent XNA types. For example: Vector3F has the methods Vector3FToXna / Vector3FFromXna(Vector3) or the explicit cast operators Vector3F (Vector3F to Vector3) / Vector3F (Vector3 to Vector3F).

Content pipeline projects

If any types of DigitalRune Mathematics (such as Vector3F, Matrix44F, QuaternionF, etc.) are used in an XNA content pipeline extension library:

  • Add references to the following DLLs to your the content pipeline extension library:
    • DigitalRune.dll
    • DigitalRune.Mathematics.dll
    • DigitalRune.Mathematics.Content.Pipeline.dll
  • For all XNA content projects that use the content pipeline extension library, add references to the following DLLs to the content projects:
    • DigitalRune.Mathematics.Content.Pipeline.dll

The DigitalRune.Mathematics.Content.Pipeline.dll contains ContentTypeWriters which ensure that the data types of DigitalRune Mathematics are properly serialized. Be sure to use the XNA-specific builds of the DLLs (see Files, Folders and Dependencies).

See Also