如何创建一个筒状的骨头作为由2个点的矢量存储(头,尾)? [英] How to create a cylinderical bone stored as a vector made of 2 points (Head, Tail)?

查看:167
本文介绍了如何创建一个筒状的骨头作为由2个点的矢量存储(头,尾)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我想要的,有人的地方写了网,但我从来没有使用四元数,所以不知道如何实现它。我相信这将是一个简单的等式只是一个问题,而是如何在C / C ++ code实现?

This is what I want, somebody wrote somewhere on net but i never use quaternion before, so have no idea how to implement it. I am sure it would be just a matter of one simple equation but how to implement in c/c++ code?

    Here:
    "You could use a bone stored as a vector made of 2 points (Head,Tail).
 Since you are rotating it, Head will be the fulcrum and Tail will rotate
 around an arbitrary axis. That's a quaternion's job."

我有一个圆筒形网格的所有顶点的绝对位置,现在如果我创建两个向量/点V1(X,Y,Z)和V2(X,Y,Z)的顶端和底端,那么我将能够仅通过变换V2(上端)点,但V1(下端)应该不会改变其立场转变的网格顶点。

I have absolute positions of all vertices of a cylindrical mesh, now if I create two vectors/points V1(x, y, z) and V2(x, y, z) at top and bottom ends, then I will be able to transform the mesh vertices by just transforming the V2(top end) point, but V1(bottom end) should not change its position.

我可以在OpenGL与glutSolidCylinder,其pretty的简单的事,但在这里我想实现与网格顶点,所以每个顶点应该在顶部或底部向量/点任何更改后进行更新。

I can do in OpenGL with glutSolidCylinder, its pretty simple, but here I want to implement with mesh vertices, so each vertex should be updated after any change in top or bottom vectors/points.

感谢。

推荐答案

我用1变换矩阵+骨的长度来代替。

I use 1 transform matrix + bone length instead.

  • 你怎么知道围绕什么轴2分而已?
  • 来旋转
  • 所以请变换矩阵重新presenting骨由来
  • 在一个轴是骨轴(红色)
  • 一个是联合(绿色)的旋转轴
  • ,最后是垂直于每一个(蓝色)
  • 也骨骼大小(长度)需要(橙色)
  • How would you know around what axis to rotate from 2 points only?
  • so make transform matrix representing bone origin
  • one axis is the bone axis (red)
  • one is the rotation axis of the joint (green)
  • and the last is perpendicular to each (blue)
  • also the bone size (length) is needed (orange)

现在该网是骨子里的树

  • 在根子网的起点
  • 和顶层骨头通过关节连接到它
  • 第二层骨头连接到第一层的骨头,等等...
  • ,所以你需要添加previous骨/子网的指数是目前骨连接
  • 还可以添加连接下层骨头的名单,以加快处理

图/计算

  • 在这个任务其实只是向前运动
  • 在这样平移/旋转根骨到所需的目标位置
  • 把它矩阵,并将其存储在一定温度
  • 在画/柄根子网/骨
  • 现在,通过所有直接connectet子网/骨头循环它
  • 在利用其矩阵计算温度的乘法和它
  • 在顺序取决于矩阵式的(行/列明智的)
  • 这可以让你的子网/骨
  • 实际矩阵
  • 在如此处理这是根子网/骨
  • 骨长度之前移动到下一个骨转换这个矩阵沿蓝轴
  • 和递归处理所有接下来的骨头...
  • this task is really just forward kinematics
  • so translate/rotate root bone to desired object position
  • take it matrix and store it to some temp
  • draw/handle root submesh/bone
  • now for loop through all directly connectet submeshes/bones to it
  • take its matrix and compute the multiplication of temp and it
  • order depends on matrix style (row/column wise)
  • this gets you actual matrix for submesh/bone
  • so handle this as root submesh/bone
  • before moving to next bone translate this matrix along blue axis by bone length
  • and recursively handle all next bones ...

关节旋转

  • 现在,你可以按每个骨骼加旋转的一个或两个角度
  • 在我使用自由旋转1度,所以我会旋转,就在绿轴
  • 在简单地乘以四元数没有需要旋转矩阵
  • 或者记住新的矩阵(旋转)
  • 或角度和任何使用骨前创建旋转矩阵
  • 但始终记得原来矩阵,以避免累积舍入误差

[注意事项]

  • 了解更多信息谷歌直接或正向运动学问题
  • CCD和反向运动学可以帮助
  • 有吨的OpenGL的机器人手臂的例子,这样搜索...
  • 您可任意变换运动设置单向线性和角执行器
  • for more info google direct or forward kinematics problem
  • also CCD and Inverse Kinematics may help
  • there are tons of robotic arm examples in OpenGL so search ...
  • you can transform any kinematics to set of single axis linear and angular actuators

这篇关于如何创建一个筒状的骨头作为由2个点的矢量存储(头,尾)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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