0001
0002
0003
0004
0005
0006
0007
0008
0009 clc
0010 close all
0011
0012 addpath(genpath('../General-Functions'))
0013
0014 fprintf('\n------ DEMO Duality ------\n')
0015
0016 fprintf('\nIn order to shorten the output, we display transposed vectors\n')
0017 fprintf('\nGiven: 3D points\n')
0018 X = random('bino',20,.5,[4,1]); disp(['X = [', num2str(X'),']'])
0019 Y = random('bino',20,.5,[4,1]); disp(['Y = [', num2str(Y'),']'])
0020
0021 U = random('bino',5,.5,[4,1]); disp(['U = [', num2str(U'),']'])
0022 V = random('bino',5,.5,[4,1]); disp(['V = [', num2str(V'),']'])
0023
0024
0025
0026 fprintf('\nPlanes through X and Y\n')
0027 A = null([X,Y,U]');
0028 disp(['A = [', num2str(A'),']'])
0029
0030 A = calc_Gammadual(calc_Pi(X)*Y)'*U;
0031 disp(['A = [', num2str(A'),']'])
0032
0033 B = null([X,Y,V]');
0034 disp(['B = [', num2str(B'),']'])
0035
0036 B = calc_Gammadual(calc_Pi(X)*Y)'*V;
0037 disp(['B = [', num2str(B'),']'])
0038
0039
0040 fprintf('\nCheck incidence:\n')
0041 Incidence = [A'*X A'*Y; B'*X B'*Y];
0042 disp(Incidence)
0043
0044
0045 fprintf('Lines\n')
0046 LXY = calc_Pi(X)*Y; disp(['L_XY = X cap Y = [', num2str(LXY'),']'])
0047 LAB = calc_Pidual(A)*B; disp(['L_AB = A ^ B = [', num2str(LAB'),']'])
0048
0049 fprintf('normalize L_AB\n')
0050 LAB = LAB/LAB(1)*LXY(1); disp(['L_AB = [', num2str(LAB'),']'])
0051
0052
0053 fprintf('\nCheck identity\n')
0054 should_be_zero = LXY'*calc_Dual*LAB;
0055 disp(['Check should be zero: ', num2str(should_be_zero)])
0056
0057