矩阵旋转/平移适当的乘法 [英] Appropriate multiplication of matrices for rotation/translation

查看:301
本文介绍了矩阵旋转/平移适当的乘法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了旋转/翻译对象(只有z轴和翻译仅在XY平面旋转)不只是WRT全球中心(设备中心),但也WRT其他任意点,我创建了一个算法,这是正确的(因为所有高级codeRS我曾与讨论认为是正确的),但是它采取了大量的时间来删除一个不需要翻译在执行(创建算法8月4日,并实现在同一天,此后code已被修订的15倍)。

In order to rotate/translate object (rotation only about z-axis and translation only in xy plane) not just w.r.t to global center (device center) but also w.r.t other arbitrary points, I created an algorithm, which is correct (because all senior coders I have discussed with consider it correct), but it is taking a lot of time to remove an undesired translation in the implementation (algorithm was created on August 4 and was implemented on the same day, since then the code has been revised 15 times).

下面是实施 <一个href="http://www.pixdip.com/opengles/transform.php#ALGO1">http://www.pixdip.com/opengles/transform.php#ALGO1

Here is the implementation http://www.pixdip.com/opengles/transform.php#ALGO1

的code,它是生产不需要翻译的线条都在里面:

The lines of code that are producing undesired translation are inside:

私有静态无效的UpdateModel(INT UPDOWN,浮xAngle,浮yAngle,浮zAngle){

和列举如下:

  1. Matrix.multiplyMV(GLES20Renderer._uBodyCentreMatrix,0,GLES20Renderer._ModelMatrixBody,0,GLES20Renderer._uBodyCentre,0)

物objx = GLES20Renderer._uBodyCentreMatrix [0];

objY = GLES20Renderer._uBodyCentreMatrix [1];

即使以下更改沿+ Y的不需要翻译仍然存在:

  1. objY = _uBodyCentreMatrix [1] - _uBodyCentre [1];

zAngle = 0;

DS = 0;

-0.545867f 添加到Y在每次调用 onDrawFrame()协调,因为该渲染器类的这些字段:

The value -0.545867f is added to the Y coordinate on every call to onDrawFrame(), because of these fields of the Renderer class:

私有静态最终浮动[] _uBodyCentre =新的浮动[] { - 0.019683f,-0.545867f,-0.000409f,1.0F};

受保护的静态浮动[] _uBodyCentreMatrix =新的浮动[4];

<一个href="http://www.pixdip.com/opengles/transform.php#FIELDS">http://www.pixdip.com/opengles/transform.php#FIELDS

我需要帮助理解为什么说不需要翻译发生,究竟是什么毛病转换,或者是它的算法是错误的。

可万向锁是一个问题吗?

请不要问我执行/练习简单的例子,因为我有prepared渲染器类旋转/翻译关于全球z轴,那我到这个新的任务,使用相同的类轻微在修改的UpdateModel()

Please do not ask me to perform/practice simpler examples, because I have prepared the Renderer class for rotation/translation about global z-axis, and this new task that I am into, uses the same class with slight modification in updateModel()

(请注意,所需要的旋转仅约z轴和翻译仅在xy面)

(Please note that the desired rotation is only about z-axis and translation only in xy plane)

[API 10-> 15

[API 10->15]

实际的渲染器类有两个对象:坦克炮塔(喷嘴)和罐体内,同时炮塔(喷嘴)已不期望着翻译,身体已经不需要向后平移

The actual Renderer class has two objects: tank turret(nozzle) and tank body, while turret(nozzle) has undesired forward translation, the body has undesired backward translation

的.apk有关设备中心的平移/旋转(这是很容易使opengles 2.0): http://www.pixdip.com/opengles/global.php

Apk for translation/rotation about device center (which is easy to make in opengles 2.0): http://www.pixdip.com/opengles/global.php

的.apk关于任意点的平移/旋转(已翻译不希望沿着+ Y): http://www.pixdip.com/opengles/local.php

Apk for translation/rotation about arbitrary points (which has undesired translation along +Y): http://www.pixdip.com/opengles/local.php

的.apk关于任意点的平移/旋转中的UpdateModel()只调用4次: http://www.pixdip.com/opengles/limited.php 和所需code(这应该是足够了)就在这里: http://www.pixdip.com/ opengles / code.php

Apk for translation/rotation about arbitrary points in which updateModel() is called 4 times only: http://www.pixdip.com/opengles/limited.php and required code (which should be sufficient) is here: http://www.pixdip.com/opengles/code.php

对象(喷嘴/炮塔,体)的部分正在绕自己的中心对象(这是_playerCentre)不是中心,我会在以后修改。

Parts of object (nozzle/turret,body) are currently rotating about their own centres not the centre of object (which is _playerCentre), I will modify that later.

我试图表现出的逻辑 <一个href="http://www.pixdip.com/opengles/images.php">http://www.pixdip.com/opengles/images.php

I have tried to demonstrate logic http://www.pixdip.com/opengles/images.php

推荐答案

[求助] java的浮点错误是唯一的原因。

[SOLVED] java floating point errors were the only cause

M = T * I​​ * T [INV]

M = T * I * T[inv]

没有导致成单位矩阵, 代替使用Matrix.MultiplyMM所以

did not result into an identity matrix, so instead of using Matrix.MultiplyMM

我型矩阵之间的所有的乘法

I type all the multiplications between the matrices

这篇关于矩阵旋转/平移适当的乘法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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