![Rotation and Translation about arbitrary point](https://i.stack.imgur.com/CczC5.gif)
为了旋转/平移对象(仅绕 z 轴旋转,仅在 xy 平面内平移),不仅与全局中心(设备中心)有关,而且还与其他任意点有关,我创建了一个算法,这是正确的(因为所有高级我与之讨论过的编码员认为这是正确的),but删除一个需要很长时间不需要的翻译正在实施中(算法于8月4日创建,并于同一天实施,此后代码已修改15次)。
这是实现http://www.pixdip.com/opengles/transform.php#ALGO1
产生不需要的翻译的代码行位于内部:
private static void updateModel(int upDown, float xAngle, float yAngle, float zAngle) {
并列出如下:
Matrix.multiplyMV(GLES20Renderer._uBodyCentreMatrix, 0, GLES20Renderer._ModelMatrixBody, 0, GLES20Renderer._uBodyCentre, 0);
objX = GLES20Renderer._uBodyCentreMatrix[0];
objY = GLES20Renderer._uBodyCentreMatrix[1];
即使进行以下更改,沿 +Y 的不需要的平移仍然存在:
objY = _uBodyCentreMatrix[1] - _uBodyCentre[1];
zAngle = 0;
ds = 0;
价值-0.545867f
每次调用时都会添加到 Y 坐标onDrawFrame()
,因为 Renderer 类的这些字段:
private static final float[] _uBodyCentre = new float[]{-0.019683f, -0.545867f, -0.000409f, 1.0f};
protected static float[] _uBodyCentreMatrix = new float[4];
in http://www.pixdip.com/opengles/transform.php#FIELDS
我需要帮助来理解为什么会发生这种不需要的转换,转换到底出了什么问题,或者算法是否错误。
万向节锁会成为这里的问题吗?
请不要要求我执行/练习更简单的示例,因为我已经准备了用于全局 z 轴旋转/平移的 Renderer 类,并且我正在执行的这个新任务使用相同的类,并稍加修改updateModel()
(请注意,所需的旋转仅绕 z 轴且仅在 xy 平面内平移)
[API 10->15]
实际的Renderer类有两个对象:坦克炮塔(喷嘴)和坦克本体,当炮塔(喷嘴)有不需要的向前平移时,主体有不需要的向后平移
关于设备中心平移/旋转的apk(在opengles 2.0中很容易制作):http://www.pixdip.com/opengles/global.php
用于关于任意点的平移/旋转的 Apk(沿 +Y 具有不需要的平移):http://www.pixdip.com/opengles/local.php
用于围绕任意点进行平移/旋转的 Apk,其中 updateModel() 仅被调用 4 次:http://www.pixdip.com/opengles/limited.php所需的代码(应该足够了)在这里:http://www.pixdip.com/opengles/code.php
对象的某些部分(喷嘴/炮塔,主体)当前正在围绕自己的中心旋转,而不是对象的中心(即_playerCentre),我稍后会对其进行修改。
我试图证明逻辑http://www.pixdip.com/opengles/images.php