15
« on: July 06, 2022, 02:05:17 PM »
def placeRegion(center,size,angle):
crs = chunk.crs
T = chunk.transform.matrix
center = Metashape.Vector((center[0],center[1],center[2]))
center = T.inv().mulp(crs.unproject(center))
m = crs.localframe(T.mulp(center)) * T
R = m.rotation() * (1. / m.scale())
size = Metashape.Vector((size[0],size[1],size[2])) / m.scale() # scaling the size is required
angle = numpy.radians(angle)
rot = Metashape.Matrix([[numpy.cos(angle), -numpy.sin(angle), 0], [numpy.sin(angle), numpy.cos(angle), 0], [0, 0, 1]])
rotation = R.t() * rot
chunk.region.rot = rotation
chunk.region.center = center
chunk.region.size = size
placeRegion(center,size,angle)
doc.save()