1
Python and Java API / Re: Setting bounding box relative to world grid coordinates
« on: January 23, 2018, 05:29:05 PM »
This snippet ended up as the solution to place the region box relative to world coordinates, thanks again:
<code>
#Switch to Local Coordinates
if chunk.crs:
chunk.crs = None
crs = chunk.crs
region = chunk.region
T = chunk.transform.matrix
m = PhotoScan.Vector([10E+10, 10E+10, 10E+10])
M = -m
x_scale = 3.0
y_scale = 3.0
z_scale = 4.0
new_size = PhotoScan.Vector([x_scale, y_scale, z_scale])
new_center = PhotoScan.Vector([0.0,0.0,2.0])
region.center = T.inv().mulp(crs.unproject(new_center))
region.size = new_size
v_t = T.mulp(region.center)
R = crs.localframe(v_t) * T
region.rot = R.rotation().t()
chunk.region = region
</code>
<code>
#Switch to Local Coordinates
if chunk.crs:
chunk.crs = None
crs = chunk.crs
region = chunk.region
T = chunk.transform.matrix
m = PhotoScan.Vector([10E+10, 10E+10, 10E+10])
M = -m
x_scale = 3.0
y_scale = 3.0
z_scale = 4.0
new_size = PhotoScan.Vector([x_scale, y_scale, z_scale])
new_center = PhotoScan.Vector([0.0,0.0,2.0])
region.center = T.inv().mulp(crs.unproject(new_center))
region.size = new_size
v_t = T.mulp(region.center)
R = crs.localframe(v_t) * T
region.rot = R.rotation().t()
chunk.region = region
</code>