简体   繁体   English

即使原始枢轴不同,也可以围绕某个点旋转对象?

[英]Rotate object around a certain point, even if the original pivot is different?

How can you rotate an object (let's say, its positions are at (5, 5, 0)) with the pivot point at let's say (3, 4, 0), even if the original point of rotation is (0, 0, 0)? 即使原先的旋转点是(0,0,),如何旋转对象(假设其位置在(5,5,0)),使枢轴点位于(3,4,0), 0)?

Here is a graphical explanation: 这是图形说明:

说明

I want to rotate the object in relation to the custom pivot point. 我想相对于自定义枢轴点旋转对象。 The object is made in blender in such a way, that the object is away from the origin (at the point (5, 5, 0)). 在混合器中以这种方式制作对象,即对象远离原点(在(5,5,0)点)。

How can we use matrices to solve this? 我们如何使用矩阵来解决这个问题?

As it was already pointed out in the comments, the easiest approach would be to translate the object so the pivot point is at the origin, then rotate the object around the origin, and then translate it back. 正如评论中已经指出的那样,最简单的方法是平移对象,使枢轴点位于原点,然后围绕原点旋转对象,然后将其平移回原处。 Each of the these steps can be done using a matrix; 所有这些步骤都可以使用矩阵来完成; multiplying these matrices should result in a matrix that does all this at once. 将这些矩阵相乘应得到一个矩阵,该矩阵可以一次完成所有这些操作。

In the given example, these matrices would be: 在给定的示例中,这些矩阵将是:

1.translation by (-3,-4,0):
    [ 1, 0, 0,-3,
      0, 1, 0,-4,
      0, 0, 1, 0,
      0, 0, 0, 1 ]

2. rotation (in this example by 90 degrees)
    [ 0, 1, 0, 0,
     -1, 0, 0, 0,
      0, 0, 1, 0,
      0, 0, 0, 1 ]

3. translation by (3,4,0)
    [ 1, 0, 0, 3,
      0, 1, 0, 4,
      0, 0, 1, 0,
      0, 0, 0, 1 ]

This would then result in the following matrix as the final transformation: 然后,将产生以下矩阵作为最终转换:

    [ 0, 1, 0,-1,
     -1, 0, 0, 7,
      0, 0, 1, 0,
      0, 0, 0, 1 ]

You may need to change the order of multiplication depending on your implementation details, but in general this should work. 您可能需要根据实现细节来更改乘法顺序,但是通常这应该可行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM