简体   繁体   English

定义边界框的坐标

[英]Define coordinates of bounding box

I have a 3d scene containing a line with coordinates Xa,Ya,Za for one side and Xb,Yb,Zb for the other side: 我有一个3d场景,其中一侧的坐标为Xa,Ya,Za,另一侧的坐标为Xb,Yb,Zb: 在此处输入图片说明

How to determine the 3d coordinates (Xa1,Ya1,Za1,Xa2,...Zb4) of a bounding box for this line, having in addition to above data, the width and height of this box, and the rotation angle on its axis: 如何确定此线的边界框的3d坐标(Xa1,Ya1,Za1,Xa2,... Zb4),除了上面的数据外,还具有该框的宽度和高度以及其轴上的旋转角度: 在此处输入图片说明

Thanks 谢谢

Essentially what you have to do is establish a suitable orthonormal coordinate basis, so that one basis vector points along the given line while other two are orthogonal to that. 本质上,您要做的是建立一个合适的正交坐标基,这样一个基矢量沿着给定的线指向,而另两个矢量正交于该点。 The actual choice depends on the angle you're mentioning, but you need some reference direction to decide angle zero. 实际选择取决于您要提及的角度,但是您需要一些参考方向来确定角度零。

Usually I'd say let a be the normalized (to length 1) vector from one of the points to the other. 通常,我会说让a为从一个点到另一个点的标准化(到长度1)向量。 Let v be some fixed reference direction, eg “up”. v为某个固定参考方向,例如“向上”。 Make sure that a and v are independent, ie pointing in different directions. 确保av是独立的,即指向不同的方向。 Compute the cross product a × v , normalize to unit length, and call that b . 计算叉积a × v ,归一化为单位长度,并将其称为b It will be a vector orthogonal to both a and v and therefore something like the direction away from the line in a horizontal plane, if v was up. 如果v向上,它将是与av都正交的向量,因此,它类似于在水平面上远离直线的方向。 Compute c = a × b which will be the third basis vector, orthogonal to a and b and already at unit length. 计算c = a × b ,这将是第三基矢量,与ab正交,并且已经存在单位长度。

Now take either endpoint and add ± w /2∙ b ± h /2∙ c to that, where w and h are the dimensions of the bounding box. 现在取任一端点,并在其上加上± w / 2∙ b ± h / 2∙ c ,其中wh是边界框的尺寸。 This gives you the 8 corner points of your bounding box. 这为您提供了边界框的8个角点。 If you want to rotate the box around the line, apply a two-dimensional rotation to the vectors b and c : 如果要围绕直线旋转框,请对向量bc进行二维旋转:

b' = cos(θ)∙ b + sin(θ)∙ c b' = cos(θ)∙ b + sin(θ)∙ c
c' = cos(θ)∙ c − sin(θ)∙ b c' = cos(θ)∙ c − sin(θ)∙ b

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM