Hi,

I have two sets of data that represent bunch of xyz coordinates of two molecules (OxF1 and TPAF1), and I need to fit these data into two planes, and then find the distance between them. I tried to do the following but I am not sure if it's right because the 3D plot I got looks a bit funny. Also, do you have any idea how to measure the distance between the two planes? I am a new user with Mathematica and your help will be greatly appreciated.

dataTPAF1 = {{5.086735, -2.640504,

4.650624}, {6.227440, -2.477485, 3.843544}, {6.160519, -1.731605,

2.649288}, {4.941969, -1.164990, 2.267181}, {3.799611, -1.315889,

3.093711}, {3.864651, -2.054553, 4.284675}, {4.609149, -0.320793,

1.036262}, {3.147213, 0.034489, 1.303689}, {2.295200, 0.817536,

0.531891}, {0.950277, 1.010999, 0.934789}, {0.504240, 0.379798,

2.123730}, {1.354565, -0.416580, 2.898054}, {2.686409, -0.582108,

2.489055}, {0.024258, 1.821306, 0.114273}, {-1.353392, 1.513264,

0.069868}, {0.471982, 2.897945, -0.687157}, {-2.233955,

2.208380, -0.751826}, {-0.408676,

3.621409, -1.497147}, {-1.775026,

3.272191, -1.550693}, {-2.675546, 3.957425, -2.411557}};

In[9]:= PlaneTPAF1 = Fit[dataTPAF1, {1, x, y}, {x, y}]

Out[9]= 2.18037 - 0.200355 x - 1.20793 y

dataOXF1 = {{0.989404, -2.326574, -0.675663}, {0.466929, \

-2.898174, 0.507492}, {-0.913869, -2.780568,

0.804534}, {-1.736679, -2.093564, -0.078413}, {-1.209589, \

-1.521258, -1.260581}, {0.155306, -1.637212, -1.561214},

{-3.234276, -1.809443,

0.054719}, {-3.478451, -0.951209, -1.195212}, {-4.647861, \

-0.326679, -1.645893}, {-4.618728, 0.428750, -2.833379}, {-3.433297,

0.549231, -3.579976}, {-2.261558, -0.087363, -3.148840}, \

{-2.289342, -0.827551, -1.957816}, {1.326341, -3.595313,

1.453222}, {3.114413, -4.428375, 2.270776}, {2.668207, -3.758639 ,

1.167271}, {1.006758, -4.128596,

2.609730}, {2.180810, -4.675522, 3.140752}};

In[16]= PlaneOXF1 = Fit[dataOXF1, {1, x, y}, {x, y}]

Out[16]= -4.19445 - 0.401548 x - 1.7137 y

Show[ListPlot3D[dataTPAF1, PlotStyle -> Red],

ListPlot3D[dataOXF1, PlotStyle -> Green],

Plot3D[{PlaneTPAF1, PlaneOXF1}, {x, -7, 7}, {y, -7, 7}]]