Reputation: 155
Given the locations of the vertices of a cuboid in 3D space (8x3
matrix), how can I calculate the following:
The box i'm working with is a bounding box for 3D object detection. So we can assume that there is no rotation at all along the pitch and roll axis (if that helps). Below shows an example of the setup i have:
I've been able to find stuff online for the inverse calculation, from dimensions to vertices. But i can't find anything in this direction. Would really appreciate any help!
Upvotes: 0
Views: 2251
Reputation: 80187
Assuming that initially edge P0-P1 was directed along OX axis, we can find rotation angle around OZ axis as
angle = atan2(P1.y - P0.y, P1.x - P0.x)
(atan2
function gives results in radians in the most of languages)
Box center is just a middle of any space diagonal (0-6, or 2-4 etc)
cx = (P0.x + P6.x) / 2
cy = (P0.y + P6.y) / 2
cz = (P0.z + P6.z) / 2
Upvotes: 1