0

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!

  • `lm` is not the right tool. I've done some related tasks in 2D, but not the one you need. You'll need to look around, someone has surely solved this. There are quite a few good online resources for geometry. Be certain to look for 3D solutions, and even though you are thinking about points that define line segments, the answers you find might be expressed in other algebraic terms (lines can be defined several ways). There are several other stackoverflow sites that might be helpful too. – Bryan Hanson Jan 10 '16 at 13:47
  • Thanks so far, Bryan! I've been looking around quite a lot but I never got any hits for my problem - as I am not so much into the maths behind, it might be my insufficient search terms. But I'll continue searching... – kruemelprinz Jan 10 '16 at 14:36
  • [This](http://geomalgorithms.com/a07-_distance.html) explains how it is done, using two points and unit vectors pointing in the correct directions (sort of like a slope). I searched for "closest point of approach 3d lines". Obviously this is not an R function, but it might give you some ideas. – Bryan Hanson Jan 10 '16 at 14:51

0 Answers0