3D line intersection without least square fitting
Show older comments
Hello all,
I am trying to find the intersect between two lines see figure below

The intersection I am interested in is the intersection between the line through the yellow open circles (data) and the line through the blue open circles (asw). The line through the yellow open circles has to have the same slope as the line through the red open circles(air). The line through the yellow open circles currently doesn't intersect in space the line of interest as the line is currently going through the average of the yellow data, making it a bit offset.
Code:
%for least-squares fitting when slope is pre-determined
%ASW data for 0 to 40 degrees C
%ASW values
%argon (x10^-4)
ArASW=[0.000538937
0.000477231
0.000427467
0.000386771
0.000353045];
ArASWflip=ArASW';
%krypton x10^-7
KrASW=[1.10092E-07
9.3735E-08
8.07418E-08
7.02917E-08
6.17893E-08];
KrASWflip=KrASW';
%xenon x10^-8
XeASW=[1.93592E-08
1.59429E-08
1.33356E-08
1.13189E-08
9.73986E-09];
XeASWflip=XeASW';
%x, y, and z are noble gas data
%xenon
x=[1.36E-08
1.54E-08
1.55E-08
1.88E-08
1.73E-08];
xflip=x';
%argon
y=[5.78E-04
5.48E-04
6.35E-04
8.07E-04
7.26E-04];
yflip=y';
%krypton
z=[1.07E-07
1.21E-07
1.21E-07
1.48E-07
1.35E-07];
zflip=z';
%air for each element starting at ASW line, so SHOULD intersect ASW line
%xenon at 0 degrees
airx=[1.93592E-08
2.80592E-08
3.67592E-08
5.41592E-08
6.28592E-08];
airxflip=airx';
%argon at 0
airy=[0.000538937
0.001472937
0.002406937
0.004274937
0.005208937];
airyflip=airy';
%krypton at 0
airz=[1.10092E-07
2.24092E-07
3.38092E-07
5.66092E-07
6.80092E-07];
airzflip=airz';
%make them columns of data
asw=cat(2,XeASW,ArASW,KrASW);
air=cat(2,airx,airy,airz);
data=cat(2,x,y,z);
%get means of each column
avgasw=mean(asw);
avgair=mean(air);
avgdata=mean(data);
%equations of the lines
%asw
asw2=bsxfun(@minus,asw,avgasw);
[~,~,aswV]=svd(asw2,0);
air2=bsxfun(@minus,air,avgair);
[~,~,airV]=svd(air2,0);
data2=bsxfun(@minus,data,avgdata);
[~,~,dataV]=svd(data2,0);
%draw a line for ASW
dasw=aswV(:,1)';
lineaswavg=[avgasw dasw];
%draw a line for air
dair=airV(:,1)';
lineairavg=[avgair dair];
%and then for data using air d
linedataavg=[avgdata dair];
%for plotting needs package geom3D
figure('color','w');
axis([-0.5E-8 0.5E-7 -1 1 -0.5E-8 0.5E-6]);
drawPoint3d(gca,asw);
drawLine3d(lineaswavg);
hold on
drawPoint3d(gca,air);
drawLine3d(lineairavg);
hold on
drawPoint3d(gca,data);
drawLine3d(linedataavg);
Any available packages I have found make a LMS fit from the data and give an intersection point. But I would like these slopes to determine where the intersection should be, and then calculate the intersection point.
Any help would be GREATLY appreciated.
5 Comments
So you want to fit the yellow open circles subject to the following constraints?
- Direction vector/slope of the yellow line matches a given vector.
- Line through yellow circles is coplanar with line through blue circles.
If this is not what you want, please clarify the constraints.
Also, is the line through the blue circles already fixed and given, or is the idea to simultaneously co-fit two lines, one through the blue open circles and one through the yellow?
dpb
on 15 Jun 2018
For the data shown, doesn't really appear there's any correlation at all between the yellow and red...not that that really solves the problem but it makes me wonder if it's realistic to do so.
Barbara Wortham
on 18 Jun 2018
Barbara Wortham
on 18 Jun 2018
dpb
on 18 Jun 2018
" there is not supposed to be a correlation between the red and yellow circles"
Well, that's good, then... :)
Actually, it would appear the range of the experiment in whatever is the z-axis direction is so limited as to make any estimate of a variation in the direction of the red data essentially meaningless.
Answers (0)
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!