简体   繁体   English

如何通过点和法线获取平面顶点

[英]How to get plane-vertices by a point and normal

I'm having a point p and a normal n (in 3d space). 我有一个点p和一个正常的n (在3d空间中)。 I want to calculate 4 vertex-points which are lying on the plane which is perpendicular to the normal and lies on the point p . 我想计算4个顶点,它们位于垂直于法线并位于p的平面上。

The vertices should form a rectangle and p should be the center of this rectangle. 顶点应形成一个矩形, p应该是该矩形的中心。

在此处输入图片说明

Here's something to get you started: 以下是一些入门知识:

Every vector on the plane is orthogonal to the normal to the plane. 平面上的每个向量都正交于平面的法线。 Ie, for an arbitrary point x on the plane, (x - p) is a vector parallel to the plane and its dot product with the given normal n is zero: 即,对于平面上的任意点x, (x - p)是平行于平面的向量,并且其点积与给定法线n为零:

n*(x - p) = 0

This should give you the equation of the plane and allow you to find as many points on the plane as you need. 这将为您提供平面方程,并允许您在平面上找到所需的任意点。

Edit: An example: 编辑:一个例子:

n = (n1,n2,n3) ;  p = (p1,p2,p3); x = (x1,x2,x3)

n1*(x1-p1) + n2*(x2-p2) + n3*(x3-p3) = 0

Now set for example, x1=0; x2=0 现在设置为x1=0; x2=0 x1=0; x2=0 and extract x3 from the equation. x1=0; x2=0并从等式中提取x3 Similarly, it is possible to set x1=0; x3=0 同样,可以将x1=0; x3=0设置x1=0; x3=0 x1=0; x3=0 and determine x2 , etc. x1=0; x3=0并确定x2

One very useful tool is the cross product (from high school analytic geometry). 一个非常有用的工具是叉积 (来自高中解析几何)。 This takes as an input an ordered pair of 3-dimensional vectors v and w, and produces a 3-dimensional vector vxw perpendicular to both, whose length is the area of the parallelogram whose sides are v and w, hence which is nonzero when v and w are not parallel. 这将一对有序的3维向量v和w作为输入,并产生一个垂直于两者的3维向量vxw,其长度是边为v和w的平行四边形的面积,因此当v时非零和w不平行。 Implement the cross product yourself, or find it in a vector library, or look at this question . 自己实现叉积,或在向量库中找到它,或查看此问题

Given n, choose a vector v that is not parallel. 给定n,选择一个不平行的向量v。 nxv is perpendicular to n. nxv垂直于n。 Normalize this to get a unit vector u1 perpendicular to n. 对其进行归一化以获得垂直于n的单位矢量u1。 nxu1 is perpendicular to both n and u1. nxu1垂直于n和u1。 Normalize this to get u2. 归一化以获得u2。 The points p+-u1, p+-u2 form a square with side length sqrt(2) whose center is p. 点p + -u1,p + -u2形成一个边长为sqrt(2)的正方形,其中心为p。

It is natural to want to have a way to choose the points continuously. 想要有一种连续选择点的方法是很自然的。 This is impossible even if you restrict to unit vectors n by the Hairy Ball Theorem . 即使通过毛毛球定理限制单位矢量n,这也是不可能的。 You have to allow a discontinuous choice of v. For example, you could use v = (1,0,0) unless n is a nonzero multiple of (1,0,0), and then use v = (0,1,0) there. 您必须允许v的不连续选择。例如,您可以使用v =(1,0,0),除非n是(1,0,0)的非零倍,然后使用v =(0,1, 0)在那里。

A way to find vectors orthogonal to your original vector that does not even involve transformations is simply reordering the coordinates. 查找与原始矢量正交甚至不涉及转换的矢量的方法就是简单地对坐标重新排序。 For any vector (x,y,z), one orthogonal would be (y,z,x), and then (z,x,y) would be orthogonal to both. 对于任何向量(x,y,z),一个正交将是(y,z,x),然后(z,x,y)将与两个正交。

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

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