I am performing an Xray investigation where I want to find coordinates for radioopaque markers in a 3D-space. Using a C-arm, I acquire two images of the same marker, one from bottom-to-top and one from the side. From the Xray source (P1 in bottom-top, P3 in side image), the marker projects to the image I get on the image intensifier ("my registrations", giving me P2 and P4, respectively) for each of the both projections . Points are given in (x,y,z) format.
I would like to define lines P1-P2 and P3-P4 and find the point where they intersect.
Is this as simple as using the following or does the lm() operation not work in 3D?
P1 <- c(0,50,50)
P2 <- c(0,-50,50)
fit <- lm(P1~P2)
Because of inaccuracies turning the Xray equipment, it might be possible that there is no point of intersection, so I would need to approximate it by finding the point with the least distance to both lines.
As you can probably tell from my formulations I have some very basic understanding of R but I am no Maths/Programming/Statistics ace, so any help finding line equations to work with in order to find their intersect (or nearest approximation of that) would be highly appreciated.
Thanks in advance!