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

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

问题描述

在人工智能课程中,我们有一个机器人,它的手臂有 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 或矩阵生成代码,我已经单独测试了所有这些.

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...

非常感谢任何帮助或想法.

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.

您的代码似乎相当于以下伪代码:

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.

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

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