Mapping coordinates from plane given by normal vector to XY plane

谁说我不能喝 提交于 2019-11-28 08:49:42

Your pane is defined by a normal vector

n=(xn,yn,zn)

For coordination transformation we need 2 base vectors and a zero point for the pane

Base vectors

We chose those "naturally" fitting to the x/y pane (see later for edge case):

b1=(1,0,zb1)
b2=(0,1,zb2)

And we want

b1 x b2 = n*c (c const scalar)

to make sure these two are really bases

Now solve this:

b1 x b2= (0*zb2-zb1*1,zb1*0-1*zb2,1*1-0*0) = (zb1,zb2,1)
zb1*c=xn
zb2*c=yn
1*c=zn

c=zn,
zb2=yn/c=yn/zn
zb1=xn/c=xn/zn

b1=(1,0,yn/zn)
b2=(0,1,xn/zn)

and normalize it

bv1=(1,0,yn/zn)*sqrt(1+(yn/zn*yn/zn))
bv2=(0,1,yn/zn)*sqrt(1+(xn/zn*xn/zn))

An edge case is, when zn=0: In this case the normal vector is parallel to the x/y pane and no natural base vectors exist, ind this case you have to chose base b1 and b2 vectors by an esthetic POV and go through the same solution process or just chose bv1 and bv2.

Zero point

you spoke of no anchor point for your pane in the OQ, but it is necessary to differentiate your pane from the infinite family of parallel panes.

If your anchor point is (0,0,0) this is a perfect anchor point for the coordinate transformation and your pane has

x*xn+y*yn+z*zn=0,
(y0,y0,z0)=(0,0,0)

If not, I assume you have an anchor point of (xa,ya,za) and your pane has

x*xn+y*yn+z*zn=d

with d const scalar. A natural fit would be the point of the pane, that is defined by normal projection of the original zero point onto the pane:

P0=(x0,y0,z0)

with

(x0, y0, z0) = c * (xn,yn,zn)

Solving this against

x*xn+y*yn+z*zn=d

gives

c*xn*xn+c*yn*yn+c*zn*zn=d

and

c=d/(xn*xn+yn*yn+zn*zn)

thus

P0=(x0,y0,z0)=c*(xn,yn,zn)

is found.

Final transformation

is achieved by representing every point of your pane (i.e. those points you want to show) as

P0+x'*bv1+y'*bv2

with x' and y' being the new coordinates. Since we know P0, bv1 and bv2 this is quite trivial. If we are not on the edge case, we have zeroes in bv1.y and bv2.x further reducing the problem.

x' and y' are the new coordinates you want.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!