将矩阵从右手坐标系更改为左手坐标系 [英] Changing a matrix from right-handed to left-handed coordinate system

查看:71
本文介绍了将矩阵从右手坐标系更改为左手坐标系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从右手系统更改 4x4 矩阵,其中:
x为左右,y为前后,z为上下

I would like to change a 4x4 matrix from a right handed system where:
x is left and right, y is front and back and z is up and down

到左手系统,其中:
x 左右,z 前后,y 上下.

to a left-handed system where:
x is left and right, z is front and back and y is up and down.

对于向量来说很容易,只需交换 y 和 z 值,但是对于矩阵如何做呢?

For a vector it's easy, just swap the y and z values, but how do you do it for a matrix?

推荐答案

让我试着更好地解释一下.我需要将 z 轴朝上的 Blender 模型导出到 y 轴朝上的 OpenGL 中.

Let me try to explain it a little better. I need to export a model from Blender, in which the z axis faces up, into OpenGL, where the y axis faces up.

对于每个坐标 (x, y, z) 都很简单;只需交换 y 和 z 值:(x, z, y).
因为我已经交换了所有的 y 和 z 值,所以我使用的任何矩阵也需要翻转,以便具有相同的效果.

For every coordinate (x, y, z) it's simple; just swap the y and z values: (x, z, y).
Because I have swapped the all the y and z values, any matrix that I use also needs to be flipped so that it has the same effect.

经过大量搜索,我最终在 gamedev:

After a lot of searching I've eventually found a solution at gamedev:

如果你的矩阵是这样的:

If your matrix looks like this:

{ rx, ry, rz, 0 }  
{ ux, uy, uz, 0 }  
{ lx, ly, lz, 0 }  
{ px, py, pz, 1 }

要从左到右或从右到左改变它,像这样翻转它:

To change it from left to right or right to left, flip it like this:

{ rx, rz, ry, 0 }  
{ lx, lz, ly, 0 }  
{ ux, uz, uy, 0 }  
{ px, pz, py, 1 }

这篇关于将矩阵从右手坐标系更改为左手坐标系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆