Forum

Author Topic: [SOLVED] Apply transformation matrix to a chunk  (Read 4128 times)

jnb

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
[SOLVED] Apply transformation matrix to a chunk
« on: April 03, 2020, 10:17:10 PM »
Hello,

I'm trying to apply a transformation matrix to a chunk in python, but I am struggling. 
My workflow for now :

- export a scaled model (local coordinates)
- open it in another software to give it correct orientation
- grab the corresponding matrix and apply it in Metashape

Exemple : 

Code: [Select]
import Metashape
doc = Metashape.app.document
chunk = doc.chunk
S = Metashape.Matrix().Diag([1, 1, 1, 1])

T = Metashape.Matrix([[0.9997743489568586, -0.0211954660930352, -0.0014154098306438, -13.4365763350189269],
                      [0.0000000000000000, -0.0666304947728083, 0.9977777193174494, 851.1973959656927491],
                      [-0.0212426732755011, -0.9975525697342621, -0.0666154595321578, -1634.9351050186285192],
                      [0.0000000000000000, 0.0000000000000000, 0.0000000000000000, 1.0000000000000000 ]])

chunk.transform.matrix = S * T.inv()


The model is indeed moving, but not correctly. The scale is also wrong (I have to hit update in Reference pane to get it right). So what I am doing wrong here ?
Thank you for your help !

Edit : ok, it seems I don't need to use the inverse matrix, chunk.transform.matrix = S * T is giving good results.
« Last Edit: April 09, 2020, 02:32:14 PM by jnb »