Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matrix4x4.CreateTranslation The result is flipped over? #110170

Closed
Coloryr opened this issue Nov 26, 2024 · 4 comments
Closed

Matrix4x4.CreateTranslation The result is flipped over? #110170

Coloryr opened this issue Nov 26, 2024 · 4 comments

Comments

@Coloryr
Copy link

Coloryr commented Nov 26, 2024

I try to create a Matrix4x4

Matrix4x4.CreateTranslation(300, 300, 0);

the value is

{{ {M11:1 M12:0 M13:0 M14:0}
 {M21:0 M22:1 M23:0 M24:0}
 {M31:0 M32:0 M33:1 M34:0}
 {M41:300 M42:300 M43:0 M44:1} }}

but i saw some doc say it should be

{{ {M11:1 M12:0 M13:0 M14:300}
 {M21:0 M22:1 M23:0 M24:300} 
{M31:0 M32:0 M33:1 M34:0}
 {M41:0 M42:0 M43:0 M44:1} }}

Image

Image

@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Nov 26, 2024
@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Nov 26, 2024
@EgorBo
Copy link
Member

EgorBo commented Nov 26, 2024

but i saw some doc say it should be

It's just a different order, see https://en.wikipedia.org/wiki/Row-_and_column-major_order
In case of .NET, it's column-major order here.

@huoyaoyuan huoyaoyuan added area-System.Numerics and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Nov 26, 2024
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-numerics
See info in area-owners.md if you want to be subscribed.

@tannergooding
Copy link
Member

In case of .NET, it's column-major order here.

.NET is rather row-major, not column-major. Hence why the translation appears sequentially in the W row, not the W column.

This matches how most other languages and CPU side vector/matrix math libraries operate including GLM (OpenGL Math Library) and DXM (DirectX Math Library).

GPUs typically default to column-major (although you can customize this in GLSL, HLSL, SPIR-V, etc) and so its typical to have to Transpose the matrix prior to uploading it to the GPU.

@Coloryr
Copy link
Author

Coloryr commented Nov 26, 2024

Thanks

@Coloryr Coloryr closed this as completed Nov 26, 2024
@dotnet-policy-service dotnet-policy-service bot removed the untriaged New issue has not been triaged by the area owner label Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants