Forum

Author Topic: Bounding Box and Coordinate System Conflict  (Read 2953 times)

bbbares

  • Newbie
  • *
  • Posts: 21
    • View Profile
Bounding Box and Coordinate System Conflict
« on: May 01, 2020, 05:43:57 AM »
This is hopefully my last post on my bounding box brigade. I was able to write two standalone scripts, one that orients the markers of the model downwards and another that minimizes the bounding box around the markers. It seems that the coordinate system to bounding box feature borrowed from another script functions for the model orientation but screws up the bounding box for the bounding box reduction. I figured this from the orthographic view and proceeding point data being seemingly skewed.  Both scripts work fine separately but they do not work together. My final product requires both features in succession. I have attached photos visually representing the issue.

This is the section of code I was referring to:
Code: [Select]
R = chunk.region.rot  # Bounding box rotation matrix
C = chunk.region.center  # Bounding box center vector

if chunk.transform.matrix:
    T = chunk.transform.matrix
    print(T)
    s = math.sqrt(T[0, 0] ** 2 + T[0, 1] ** 2 + T[0, 2] ** 2)  # scaling # T.scale()
    S = Metashape.Matrix().Diag([s, s, s, 1])                  # scale matrix
else:
    S = Metashape.Matrix().Diag([1, 1, 1, 1])

T = Metashape.Matrix([[R[0, 0], R[0, 1], R[0, 2], C[0]],
                      [R[1, 0], R[1, 1], R[1, 2], C[1]],
                      [R[2, 0], R[2, 1], R[2, 2], C[2]],
                      [      0,       0,       0,    1]])


Ideally there is a solution that allows the rotation of the object model without altering the coordinate system disabling me from utilizing it properly in the future.

P.S. I have two additional pictures that would aid in understanding the issue but I am limited to 4