简体   繁体   中英

How to get plane-vertices by a point and normal

I'm having a point p and a normal n (in 3d space). 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 .

The vertices should form a rectangle and p should be the center of this rectangle.

在此处输入图片说明

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:

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 and extract x3 from the equation. Similarly, it is possible to set x1=0; x3=0 x1=0; x3=0 and determine x2 , etc.

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. 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. nxv is perpendicular to n. Normalize this to get a unit vector u1 perpendicular to n. nxu1 is perpendicular to both n and u1. Normalize this to get u2. The points p+-u1, p+-u2 form a square with side length sqrt(2) whose center is 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 . 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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