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

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

问题描述

我想从一个右手系统中改变一个4x4矩阵,其中:
x是左和右,y是正面和背面,z是上和下

转换为左手系统,其中:
x是左和右, z 是正面和背面, y 是和。

对于一个向量来说很简单,只需交换y和z值,但是如何为矩阵做这件事?

解决方案

让我试着解释它好一点。
我需要将Blender中的模型(其中z轴朝上)导出到OpenGL中,其中y轴朝上。



对于每个坐标(x,y,z),这很简单;只交换y和z值:(x,z,y)。

因为我交换了所有的y和z值,所以我使用的任何矩阵也需要翻转,以便它具有同样的效果。

经过大量搜索后,我终于在








$如果你的矩阵看起来像这样:

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

将其从左到右或从右改为左转,像这样翻转:

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


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

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

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

解决方案

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.

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.

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天全站免登陆