简体   繁体   中英

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)?

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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