Hey guys i have this script that resizes the region box, however it takes into account points that are outside of the original region box, making the result very large. All i want to do is take the region box the allignment has given me and scale it up by a factor of 2 or whatever scale i give it
import Metashape, math
doc = Metashape.app.document
chunk = doc.chunk
region = chunk.region
T = chunk.transform.matrix
m = Metashape.Vector([1E+1, 1E+1, 1E+1])
M = -m
for point in chunk.point_cloud.points:
if not point.valid:
continue
coord = T * point.coord
for i in range(3):
m[i] = min(m[i], coord[i])
M[i] = max(M[i], coord[i])
center = (M + m) / 2
size = M - m
region.center = T.inv().mulp(center)
region.size = size * (2 / T.scale())
region.rot = T.rotation().t()
chunk.region = region
print("Script finished.")