Skip to content

Question about the matrix layout #254

Closed
@foggy76

Description

@foggy76

I am probably missing something very obvious but:

The directxmath documentation says that the matricies are stored row-major. But when I do

XMMATRIX T = XMMatrixTranslation(5.0f, 3.0f, 8.0f);

The 5.0f, 3.0f, and 8.0f are all stored in the last row of the matrix like this:

Image

But when I look at it from the internet it says "In row-major order, the consecutive elements of a row reside next to each other" https://en.wikipedia.org/wiki/Row-_and_column-major_order

And on math books, the translation component is represented in the most right side (the last column) of the matrix.

So if this is the math form of the matrix:

Image

Than the translation components (x, y, z in order) are located at a14, a24, a34. But that means (if you include a44) directxmath stores the column in a contiguous memory, as it stores the 3 values in a single vector.

But directxmath documentation says that is uses row major, so it should have(?) stored a11, a12, a13, a14 in order. So I would expect to see:

1, 0, 0, 5,
0, 1, 0, 3,
0, 0, 1, 8,
0, 0, 0, 1,

continuously in the memory.

Am I missing something obvious or what is going on here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions