围绕特定点旋转(例如,围绕 0,0,0 旋转) [英] Rotation around a specific point (eg, rotate around 0,0,0)

查看:29
本文介绍了围绕特定点旋转(例如,围绕 0,0,0 旋转)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在搜索这个问题,但我真的找不到合适的答案.
我需要围绕给定点(例如,0,0,0)旋转圆柱体,但默认情况下给出圆柱体的枢轴.怎么改?

I've been searching a lot on this problem, but I couldn't really find an answer that would fit.
I need to rotate a cylinder around a given point (eg, 0,0,0), but the pivot of the cylinder is given by default. How do i change that?

我发现 这个主题,这正是我想做的,但我不知道如何用java来做.

I found this topic, and it's quite what I would want to do, but I don't know how to do it with java.

为了更好地解释我想要做什么,我将展示 3 张图片.(v)

To explain better what I would like to do, I'll show 3 images.(v)

imageshack.us/photo/my-images/259/aintgood.jpg

imageshack.us/photo/my-images/259/aintgood.jpg

imageshack.us/photo/my-images/840/whatineed.jpg

imageshack.us/photo/my-images/840/whatineed.jpg

imageshack.us/photo/my-images/705/nogoodn.jpg

imageshack.us/photo/my-images/705/nogoodn.jpg

所以,第一张图片显示了我的基本问题,圆柱体的末端应该位于球体的中心,比如说 (0,0,0).用户给出两个角度.第一个用于 rotX 命令,第二个用于 rotZ 命令.圆柱体的枢轴位于其中心,因此,如图 3 所示,即使我平移圆柱体使其末端位于球体的中心,当它旋转时,整个物体都会毁掉.

So, the first image shows my basic problem, the cylinder should be positioned with the end at the center of the sphere, let's say (0,0,0). The user gives two angles. The first one is for a rotX command, the second one for a rotZ one. The pivot of the cylinder is at its center, so, as image 3 shows, even if i translate the cylinder so its end is at the center of the sphere, when it rotates, the whole thing ruins.

图 2 显示了圆柱-球体组的外观,无论给定的角度如何.图像不是基于算法得到的,而是基于微积分,鼠标旋转得到的.

Image 2 shows what the cylinder-sphere group should look like, regardless the given angles. The image is not obtained based on an algorithm, but based on calculus, and mouserotated.

推荐答案

绕任意点P旋转的一般过程是:

The general procedure for rotation about an arbitrary point P is:

  1. 按 -P 平移(所以 P 在 (0, 0, 0))
  2. 绕原点旋转
  3. 由 P 平移(将原点带回到 P 的原始位置)

最简单的方法是在 齐次坐标 中表示所有内容并表示平移和旋转通过矩阵.组合上述三个变换(translate-rotate-translate)是通过矩阵乘法完成的.如果旋转由两个或多个更简单的旋转组成,则旋转矩阵本身就是更简单旋转的矩阵的乘积.

The easiest way to do this is to represent everything in homogeneous coordinates and represent translations and rotations by matrices. Composing the above three transformations (translate-rotate-translate) is done by matrix multiplication. If the rotation is composed of two or more simpler rotations, then the rotation matrix itself is a product of the matrices for the simpler rotations.

这篇关于围绕特定点旋转(例如,围绕 0,0,0 旋转)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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