查找矩形的角,给定的平面方程,高度和宽度 [英] Find Corners of Rectangle, Given Plane equation, height and width

查看:93
本文介绍了查找矩形的角,给定的平面方程,高度和宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上,我想一直使矩形平面面向对象.

Essentially I want to make a rectangular plane face an object at all times.

1)我找到了我的平面方程(ax + by + cz + d = 0)

1) I have found my plane equation (ax + by + cz + d = 0)

2)我有一个位于平面上的矩形的中心点(P0 =(x0,y0,z0)).

2) I have the center point of the rectangle (P0 = (x0,y0,z0)), which lays on the plane.

3)我有矩形的宽度和高度. (宽,高)

3) I have the width and Height of the rectangle. (W, H)

4)我知道矩形的顶部两个角将具有相等的Y值,这也适用于底部2个角. (Y是我的上下轴,矩形的顶部和底部线条将始终平行于x,z平面)

4) I know that the top two corners of the rectangle will have equal Y values, this goes for bottom 2 corners also. (Y is my up and down axis, the rectangle top and bottom lines will always be parallel to the x,z plane)

有人知道如何找到四个角C1,C2,C3,C4的x,y,z值吗?

Does anyone know how to find the x,y,z values of the four corners C1,C2,C3,C4?

推荐答案

计算从平面中心到要面对的对象的向量.将该向量称为V.然后将normalize(V)=(a,b,c)和d =-a * x0-b * y0-c * z0.你有飞机的方程式.

Compute the vector from your plane center to the object you want to face. Call that vector V. Then normalize(V) = (a, b, c) and d = - a*x0 - b*y0 - c*z0. You have the equation for your plane.

现在,您可以根据需要旋转平面.如果您要使飞机的侧倾为0(即仅修改偏航角和俯仰角),则可以采用世界上"矢量(0,0,1)和normalize(V)的归一化叉积来获得矩形的水平向量U.取normalize(V)与U的归一化叉积,以获得矩形的垂直矢量W.

Now you can rotate the plane however you want. If you to have the plane to have 0 roll (that is, only ever modify yaw and pitch), you can take the normalized cross product of the world "up" vector (0,0,1) and normalize(V) to get the horizontal vector U for the rectangle. Take the normalized cross product of normalize(V) and U to get the vertical vector W for the rectangle.

矩形的角现在是:

C1 = P0 +(宽度/2)* U +(高度/2)* W
C2 = P0 +(宽度/2)* U-(高度/2)* W
C3 = P0-(宽度/2)* U +(高度/2)* W
C4 = P0-(宽度/2)* U-(高度/2)* W

C1 = P0 + (width / 2) * U + (height / 2) * W
C2 = P0 + (width / 2) * U - (height / 2) * W
C3 = P0 - (width / 2) * U + (height / 2) * W
C4 = P0 - (width / 2) * U - (height / 2) * W

请注意,当矩形位于应该面对的对象的上方或下方时,此方法具有奇异性.您应该检查是否适当,并在您的情况下进行处理.

Note that this approach has a singularity when the rectangle is directly above or below the object it is supposed to face. You should check for that if appropriate and handle it however makes sense in your scenario.

这篇关于查找矩形的角,给定的平面方程,高度和宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆