Bounding box calculations in 3d-tiles

60 views
Skip to first unread message

emapsit...@gmail.com

unread,
Jan 16, 2019, 7:07:49 AM1/16/19
to cesium-dev
I am having some difficulty understanding the boundingVolume box. All of the examples in the 3d-tiles-samples repo appear somewhere near Philadelphia. For example, the TilesetWithTreeBillboards has coordinates in radians, that once multipled by PI/180 yield the lat/lon coordinates of 40.041, -75.612.

However, in the TilesetWithDiscreteLOD, https://github.com/AnalyticalGraphicsInc/3d-tiles-samples/blob/master/tilesets/TilesetWithDiscreteLOD/tileset.json, which appears in the same place near Philadelphia, there is a boundingVolume Box:
"boundingVolume": {
"box": [
0,
0,
0,
7.0955,
0,
0,
0,
3.1405,
0,
0,
0,
5.0375
]
}

and a transform:

"transform": [
96.86356343768793,
24.848542777253734,
0,
0,
-15.986465724980844,
62.317780594908875,
76.5566922962899,
0,
19.02322243409411,
-74.15554020821229,
64.3356267137516,
0,
1215107.7612304366,
-4736682.902037748,
4081926.095098698,
1
]

I can see that this is a rotation, and translation matrix (scale being 0), but what are the units and how do these two matrices in conjunction resolve to a lat/lon (or ECEF) equivalent somewhere near Philadelphia. I have tried various linear algebra combinations, and Cesium.transforms but am drawing a blank.

I have looked at the Javascript code in https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/specification#tile-transforms. But this has not helped at all, as the normalTransform calculated there, is not used in the rest of the code.

Apologies for what is no doubt a very daft question, but, I have only worked in projected coordinate systems in the past.

Omar Shehata

unread,
Jan 17, 2019, 9:49:19 AM1/17/19
to cesium-dev
So you can see what each of the numbers in "box" represent here in the spec:


And you can see exactly how they're transformed in CesiumJS:


Notice how the center point is transformed by the matrix, and then the rotation and scale are extracted and applied to the dimensions of the box. So in the example case in your post, the box center is at (0,0,0), so its position ends up as the translation component of the transform matrix (reproduced below with rounded numbers just to make it easier to read):

96,       24,      0,      0,
-15,      62,      76,     0,
19,      -74,      64,     0,
1215107, -4736682, 4081926, 1

So the first 3 numbers in the last row is where it's positioned. And if we try this in Sandcastle, we can see that it is indeed the same place just outside of Philadelphia:

var viewer = new Cesium.Viewer('cesiumContainer');

var location = new Cesium.Cartesian3(1215107, -4736682, 4081926);

viewer
.camera.flyTo({
    destination
: location
});


Message has been deleted
Message has been deleted

emapsit...@gmail.com

unread,
Jan 18, 2019, 6:23:36 AM1/18/19
to cesium-dev
Omar, thank you so much for answering that.
My confusion was in not comprehending that Cartesian in this context meant meters from the center of the earth. If have gone through the relevant parts of the transforms and 3d tile code now and it makes sense.


var lng = -1.3197004795898053;
var lat = 0.698858210;
var center = Cesium.Cartesian3.fromRadians(lng, lat, 0);
var transform = Cesium.Transforms.eastNorthUpToFixedFrame(center);

console.log(transform);

(0.96, -0.159, 0.19, 214930)
(0.24, 0.62, -0.74, -4736396)
(0, 0.76, 0.64, 4081525)
(0, 0, 0, 1)

which is the same as the transform matrix in the tileset.json above, but with the rotations scale by 100.

Reply all
Reply to author
Forward
0 new messages