Efficient 4x4 matrix inverse (affine transform)

后端 未结 5 666
自闭症患者
自闭症患者 2020-12-23 02:20

I was hoping someone can point out an efficient formula for 4x4 affine matrix transform. Currently my code uses cofactor expansion and it allocates a temporary array for ea

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-23 02:41

    IIRC you can greatly shrink the code and time by precomputing a bunch (12?) 2x2 determinants. Split the matrix in half vertically and compute every 2x2 in both the upper and lower half. One of these smaller determinants is used in every term you'll need for the bigger computation and they each get reused.

    Also, don't use a separate determinant function - reuse the sub-determinants you computed for the adjoint to get the determinant.

    Oh, just found this.

    There are some improvements you can make knowing its a certain kind of transform too.

提交回复
热议问题