Home > 05-08-Geometry > demo_3D_Lines2Point.m

demo_3D_Lines2Point

PURPOSE ^

% Demo intersection and join of 3D lines

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

% Demo intersection and join of 3D lines


 Wolfgang Förstner
 wfoerstn@uni-bonn.de

 last changes: Susanne Wenzel 07/17
 wenzel@igg.uni-bonn.de

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %% Demo intersection and join of 3D lines
0002 %
0003 %
0004 % Wolfgang Förstner
0005 % wfoerstn@uni-bonn.de
0006 %
0007 % last changes: Susanne Wenzel 07/17
0008 % wenzel@igg.uni-bonn.de
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 % Given points on lines
0019 X = [ 2,1,2,1]';
0020 Y = [ 6,1,2,1]';
0021 % intersecting lines
0022 Z = [ 3,2,2,1]';
0023 T = [ 3,7,2,1]';
0024 % % non-interesecting lines
0025 % Z = [ 3,2,6,1]';
0026 % T = [ 3,7,6,1]';
0027 % line at infinity
0028 % Z = [ 3,2,2,0]';
0029 % T = [ 3,7,2,0]';
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 %% Intersection point X of two 3D-lines L and M
0047 fprintf('\nPoint closest to lines\n')
0048 
0049 % general solution: any position but lines are not equal
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 % finite solution: for lines that are not parallel
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 %% Plane through two 3D-lines L and M
0064 fprintf('\nPlane closest to lines\n')
0065 
0066 % general solution: lines are coplanar and not equal
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 % finite solution: for lines that are not parallel
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

Generated on Sat 21-Jul-2018 20:56:10 by m2html © 2005