简体   繁体   English

通过中心,法线,长度和高度获取矩形顶点

[英]Get rectangle vertices by center, normal, length and height

I am looking for a way to get all the vertices of a rectangle whose center, normal, length and height I know. 我正在寻找一种获取矩形的所有顶点的方法,该矩形的中心,法线,长度和高度我都知道。 I am a little weak in maths so please help me. 我的数学有点虚弱,所以请帮助我。 Edit : the plane is in 3D space. 编辑:飞机在3D空间中。

You can easily calculate the x and y coordinates of the vertices of a rectangle in 2D space given the center, width and height by subtracting/adding half the width/height from the x/y position of the center point. 在中心,宽度和高度给定的情况下,通过从中心点的x / y位置减去宽度/高度的一半,可以轻松地计算出矩形在2D空间中的顶点的x和y坐标。

If you need this in 3D space, this becomes a little more tricky and relies on a bit of trigonometry, but still follows the same principle. 如果您在3D空间中需要此功能,这将变得有些棘手,并且需要一些三角函数,但仍要遵循相同的原理。 You'll need one extra piece of information. 您将需要一条额外的信息。 You need some way of fixing the orientation of the square in some direction; 您需要某种方式将正方形的方向固定在某个方向上。 ie, which direction is the rectangle 'facing'. 即,矩形“朝向”哪个方向。 The normal will allow you to work out what plane the rectangle is on, but without some orientation on that plane, the best you can do is work out a set of possible values in a circle around the center for each of the vertices. 法线将允许您计算出矩形所在的平面,但是在该平面上没有任何方向的情况下,最好的办法是为每个顶点在中心周围的圆中计算出一组可能的值。

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

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