Find the projection of A onto the normal direction. Then subtract that projection from A
. What is left is the projection of A
onto the orthogonal plane.
The projection of A onto the unit normal direction n
is given by:
(A · n) n
If A = (x, y, z)
and the unit normal is given by n = (nx, ny, nz)
, then the projection of A onto n
is
(x*nx + y*ny + z*nz) n
So the projection of A onto the orthogonal plane is
A - (A · n) n
= (x, y, z) - (x*nx + y*ny + z*nz) (nx, ny, nz)
For example, if A = (1,2,3) and n is the unit normal in direction (4,5,6), then
In [12]: A
Out[12]: array([1, 2, 3])
In [17]: d
Out[17]: array([4, 5, 6])
In [20]: n = d/sqrt(4*4 + 5*5 + 6*6) # make n a unit vector
In [13]: n
Out[13]: array([ 0.45584231, 0.56980288, 0.68376346])
So the projection of A onto the orthogonal plane is
In [15]: A - np.dot(A,n)*n
Out[15]: array([-0.66233766, -0.07792208, 0.50649351])
How to find 2D coordinates:
You'll need to define a 2D coordinate system on the orthogonal plane. In other words, you need to define where the x-axis
and y-axis
are. For example, you could define the x-axis
to be the projection of (1,0,0) onto the orthogonal plane (using the computation shown above). This will work except in the degenerate case where (1,0,0) is normal to the plane.
Once you have unit vectors for the x
and y
axis directions, then you could project A
directly onto x
and y
. The magnitude of those vectors are the 2D coordinates.
For example, this is the projection of (1,0,0) onto the plane. We take this to be the x-axis direction:
In [42]: x = np.array([1,0,0])
In [45]: x = x - np.dot(x, n) * n
In [52]: x /= sqrt((x**2).sum()) # make x a unit vector
In [53]: x
Out[53]: array([ 0.89006056, -0.29182313, -0.35018776])
Here we compute the y-axis direction: The y-axis
direction must be perpendicular to both the normal direction n
and to x
. So we could define y
to be the cross product of n
and x
:
In [68]: y = np.cross(n, x)
In [69]: y
Out[69]: array([ -2.77555756e-17, 7.68221280e-01, -6.40184400e-01])
So here are the coordinates for A
in the plane:
In [70]: np.dot(A, x), np.dot(A, y)
Out[70]: (-0.74414898890755965, -0.38411063979868798)