Forum

Author Topic: define cubic region for bounding box  (Read 2085 times)

Twister

  • Newbie
  • *
  • Posts: 24
    • View Profile
define cubic region for bounding box
« on: August 09, 2018, 10:01:49 AM »
Hi everybody,

I want to replace the existing region of a referenced chunk by a new cubic region, centered to [0,0,0] and aligned to the local coordinates of chunk, with a cube side length side_length. What would be the easiest way to do this? Thank you in advance.

Best regards

Twister

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14855
    • View Profile
Re: define cubic region for bounding box
« Reply #1 on: August 09, 2018, 08:23:23 PM »
Hello Twister,

The following code should work for the chunk referenced in Local Coordinates:

Code: [Select]
import PhotoScan

side_length = 5.0 #set value here
chunk = PhotoScan.app.document.chunk
T = chunk.transform.matrix
chunk.region.center = T.inv().mulp(PhotoScan.Vector([0, 0, 0]))
chunk.region.size = PhotoScan.Vector([side_length, side_length, side_length]) / chunk.transform.matrix.scale()
chunk.region.rot = T.rotation().t()
print("script finished.")
Best regards,
Alexey Pasumansky,
Agisoft LLC

Twister

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: define cubic region for bounding box
« Reply #2 on: August 10, 2018, 04:07:03 PM »
Thank you, Alexey, it works fine!