You cannot find ALL the points between any pair, in any number of dimensions. At best, you can describe the set of all such points, typcially as a line.
Two points define a line, in any number of dimensions. Actually, a line segment. If you extend that segment out, then it becomes a line. NO, two points cannot define a plane. There would be infinitely many planes that pass through two points.
The simplest way to define the line segment is in a parametric form. This allows the points to be vertically related, and still create a line. Thus, I would do this:
xyz1 = randn(1,3)
xyz1 =
-0.2066 0.4845 1.1696
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
xyz2 = randn(1,3)
xyz2 =
-0.9677 0.1770 0.7555
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
Now we can define the line segment as a linear combination of those two points. What I would call a convex combination.
lineseg = @(t) xyz1.*(1-t) + xyz2.*t;
lineseg is a function handle, that for any value of the parameter t, returns a point along the line connecting the points. If t lies in the interval [0,1], then the point returned will be between the two. When t==1.2, the point will be exactly in the middle. And when t==0 or t==1, you get the corresponding point. For example...
lineseg(0)
ans =
-0.2066 0.4845 1.1696
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
lineseg(1)
ans =
-0.9677 0.1770 0.7555
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
lineseg(0.5)
ans =
-0.5871 0.3307 0.9626
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
When t is outside of the interval [0,1], you get an extrapolated pooint along that line.
lineseg(2)
ans =
-1.7287 -0.1305 0.3414
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
And, if t is a (column vector) then you will get a set of points long that line.
xyz = lineseg(linspace(-1,2,100)')
xyz =
0.5544 0.7920 1.5837
0.5314 0.7827 1.5712
0.5083 0.7734 1.5586
0.4852 0.7641 1.5461
0.4622 0.7547 1.5335
0.4391 0.7454 1.5210
0.4161 0.7361 1.5084
0.3930 0.7268 1.4959
0.3699 0.7175 1.4833
0.3469 0.7081 1.4708
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
plot3(xyz(:,1),xyz(:,2),xyz(:,3),'-r')
plot3([xyz1(1),xyz2(1)],[xyz1(2),xyz2(2)],[xyz1(3),xyz2(3)],'go')
As you should see, nothing special as needed. No line fit. And again, hoping to fit a surface or a plane to two points is a meaningless endeaver, since there are infinitely many planes you could form.