3d (THREE.js) : difference matrix

℡╲_俬逩灬. 提交于 2019-12-24 10:45:24

问题


I would like to save the info that represents the relative difference between two THREE.Object3d. I prefer to save the data as a transformation matrix.

Can someone knows what do i need to do to get this?

I would like to have a matrix4 that later on i could apply on an object and it will move/rotate by the same values.

Thanks


回答1:


So you have two transformations A and B you are looking for the transformation T that transforms A into B, right? Formally this is written as

B = T · A

Now you can think of going from A to B, as going back from A to identity (I) and then from identity to B i.e.

Going back from A to I:

I = inv(A) · A

Going from I to B

B = B · I

Chaining that up you get

B = B · inv(A) · A

Add a few parentheses to highlight things:

B = ( B · inv(A) ) · A

Comparing that with the first equation we see that

T = B · inv(A)




回答2:


For each object you can do a

matrix.decompose( position, quaternion, scale )

to get back the position, quaternion and scale and then for the quaternion you can do

matrix.makeRotationFromQuaternion( quaternion )

and then store the appropriate differences you need.



来源:https://stackoverflow.com/questions/47960768/3d-three-js-difference-matrix

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!