Convert points on a 3d Plane to 2d Coordinates
As far as I understand, all points lie in the same plane, and you want to reduce dimension and later restore coordinates.
Get three non-collinear points A, B, C. Make vectors AB and AC.
Normal to that plane is
N = AB x AC //cross product
Now normalize vectors AB and N getting unit U = uAB
and uN
. Build the second base vector (it is unit and lies in the plane)
V = U x uN
Now you have four basis points A, u=A+U, v=A+V, n=A+uN
Tranformation should map these points into quadruplet (0,0,0), (1,0,0), (0,1,0), (0,0,1)
correspondingly.
Now about affine transformation matrix to make this mapping:
[Ax ux vx nx] [0 1 0 0]
M * [Ay uy vy ny] = [0 0 1 0]
[Az uz vz nz] [0 0 0 1]
[1 1 1 1 ] [1 1 1 1]
or
M * S = D
M * S * Sinv = D * Sinv
M = D * Sinv
So calculate inverse matrix for S=[Ax ux...]
and get needed matrix M.
Application of M to any point in the plane gives new coordinates with zero z-component.
Application of inverse of M to (x,y,0) results 3D coordinates in given plane.
Maple sheet with points A=1,1,1 B=2,1,1 C=1,1,2 (in plane Y=1)
new coordinates AA, BB, CC have zero z-component.
For arbitrary point in the same plane z-component after mapping is zero too.
P:=vector([-2,1,7,1]);
> PP := multiply(M, P);
PP := [-3, 6, 0, 1]