使用三维变换矩阵 [英] Using 3d transformation matrices

查看:177
本文介绍了使用三维变换矩阵的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个AI类,我们有一个机器人,有7节臂。每个关节可旋转不同的方向。我需要知道的最末端将是。我一直在努力做的3D矩阵乘法和它的作品的一个关节,但一旦我加入另一个不与模型我做了使用Java3D的API排队。这就是我想要计算第二关节的位置。

In an AI class we have a robot that has an arm with 7 joints. Each joint can rotate a different direction. I need to know where the very end is going to be. I've been trying to do 3d matrix multiplication and it works for one joint but once I add in another it doesn't line up with a model I made using the Java3D api. This is how I'm trying to calculate the position of the second joint.

double[][] b = {{0, 0, 0, 1}};

// Joint 1
b = HercMatrix.MatMul(b, HercMatrix.getTranslation(0, 0, -110));
b = HercMatrix.MatMul(b, HercMatrix.getRotation(0, arm.getJointAngle(0), 0));

// Joint 2
b = HercMatrix.MatMul(b, HercMatrix.getTranslation(0, 0, -250));
b = HercMatrix.MatMul(b, HercMatrix.getRotation(arm.getJointAngle(1), 0, 0));

System.out.println("Matrix: " + b[0][0] + ", " + b[0][1] + ", " + b[0][2]);

我想这就是他们的方式去有关应用乘法。我知道一个事实,这不是我的MATMUL或矩阵的计算产生code,我测试过的所有独立。

I imagine it's they way I go about applying the multiplications. I know for a fact it's not my matmul or matrice generation code, I've tested all that individually.

第二翻译予有需要是在第一关节的角度的相对x轴。但我不知道这是否是我该怎么办呢?

the second translation I have needs to be on the relative x-axis of the first joint's angle. But I have no idea if this is how I do it...

任何帮助或想法是极大的AP preciated。

Any help or ideas is greatly appreciated.

推荐答案

这是很难准确回答没有看到你的仿射变换矩阵结构,和角度变量的定义。在平移矩阵正常定义假定位置矢量从左边,例如,这似乎是相对于您使用相乘。还检查B [0] [3] == 1时结束。

It's difficult to answer exactly without seeing the structure of your affine transformation matrices, and the definitions of the angle variables. The normal definition of the translation matrix assumes the position vector is multiplied from the left, for example, which seems to be opposite to your use. Check also that b[0][3]==1 at the end.

您code似乎是等同于下面伪code:

You code seems to be equivalent to the following pseudocode:

b = origin.translate(Joint1).rotate(Joint1).translate(Joint2).rotate(Joint2);

这是不等同于

b = origin.translate(Joint2).rotate(Joint2).translate(Joint1).rotate(Joint1);

所以请您需要的变换顺序。

so check which order of transformations you require.

这篇关于使用三维变换矩阵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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