0001
0002
0003
0004
0005
0006
0007
0008 function [Disc] = xDiscrepancyFast(Model,Cand)
0009
0010 L = length(Cand);
0011
0012 if (L == 2),
0013
0014 C = Cand(1).Rot' * Cand(2).Rot;
0015 r1 = Model.R * C;
0016 ang1 = zAngleOfRotation(r1);
0017 r2 = Model.R' * C';
0018 ang2 = zAngleOfRotation(r2);
0019
0020 t1 = Model.T1 - (Cand(2).Center - Cand(1).Center)*Cand(1).Rot;
0021 t2 = Model.T2 - (Cand(1).Center - Cand(2).Center)*Cand(2).Rot;
0022
0023 v = Model.AngleWeight(1);
0024
0025 Disc = (sqrt(t1*t1' + (v^2)*ang1^2) + sqrt(t2*t2' + (v^2)*ang2^2))/4;
0026
0027 if (Disc > Model.LDiscCutoff),
0028 Disc = -1;
0029 end
0030
0031 else
0032
0033 MCC = Model.CenteredCenters;
0034 MWC = Model.WeightedCenteredCenters;
0035
0036 CandiCenters = cat(1,Cand.Center);
0037 CMean = Model.LocWeight * CandiCenters / Model.NumNT;
0038
0039 CC = CandiCenters - ones(L,1) * CMean;
0040
0041 R = zBestRotation(CC, MWC);
0042
0043 S = Model.LocWeight * sum(((MCC - CC*R').^2)')';
0044 n = 1;
0045
0046 while (S <= Model.LDiscCutoff) & (n <= L),
0047 ang = zAngleOfRotation(R*Cand(n).Rot*(Model.NT(n).Rot)');
0048 S = S + (ang^2)*Model.AngleWeight(n)^2;
0049 n = n + 1;
0050 end
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060 if (n > 1) & (S <= Model.LDiscCutoff),
0061 Disc = S;
0062 else
0063 Disc = -1;
0064 end
0065
0066
0067
0068 end