0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 clc
0011 close all
0012 clearvars
0013
0014 addpath(genpath('../General-Functions'))
0015
0016 fprintf('\n------ Demo point and plane closest to two 3D lines ------\n')
0017
0018
0019 X = [ 2,1,2,1]';
0020 Y = [ 6,1,2,1]';
0021
0022 Z = [ 3,2,2,1]';
0023 T = [ 3,7,2,1]';
0024
0025
0026
0027
0028
0029
0030
0031 fprintf('\nIn order to shorten the output, we display transposed vectors\n')
0032
0033
0034 fprintf('\nGiven: 3D points\n')
0035
0036 disp(['X = [', num2str(X'),']'])
0037 disp(['Y = [', num2str(Y'),']'])
0038 disp(['Z = [', num2str(Z'),']'])
0039 disp(['T = [', num2str(T'),']'])
0040 fprintf('\nGiven: 3D lines\n')
0041 L = calc_Pi(X)*Y; disp(['L = X ^ Y = [', num2str(L'),']'])
0042
0043 M = calc_Pi(Z)*T; disp(['M = Z ^ T = [', num2str(M'),']'])
0044
0045
0046
0047 fprintf('\nPoint closest to lines\n')
0048
0049
0050 Intersection_general = calc_intersect_3D_Lines2Point(L,M);
0051 disp( ['algebraic: X(L,M) = [', num2str(Intersection_general'),']'])
0052 if Intersection_general(4) ~= 0
0053 disp(['algebraic: X(L,M), normalized = [', num2str(Intersection_general'/Intersection_general(4)),']'])
0054 end
0055
0056
0057 Intersection_finite = calc_intersect_3D_Lines2Point_finite(L,M);
0058 disp(['finite: X(L,M) = [', num2str(Intersection_finite'),']'])
0059 if Intersection_finite(4) ~= 0
0060 disp(['finite: X(L,M), normalized = [', num2str(Intersection_finite'/Intersection_finite(4)),']'])
0061 end
0062
0063
0064 fprintf('\nPlane closest to lines\n')
0065
0066
0067 Plane_general = calc_join_3D_Lines2Plane(L,M);
0068 disp(['algebraic: A(L,M) = [', num2str(Plane_general'),']'])
0069 if norm(Plane_general(1:3)) ~= 0
0070 disp(['algebraic: A(L,M), normalized = [', num2str(Plane_general'/norm(Plane_general(1:3))),']'])
0071 end
0072
0073
0074 Plane_finite = calc_join_3D_Lines2Plane_finite(L,M);
0075 disp(['finite: A(L,M) = [', num2str(Plane_finite'),']'])
0076 if norm(Plane_finite(1:3)) ~= 0
0077 disp(['finite: A(L,M), normalized = [', num2str(Plane_finite'/norm(Plane_finite(1:3))),']'])
0078 end