-
Notifications
You must be signed in to change notification settings - Fork 0
/
analyzeContourPointsDistances.m
118 lines (76 loc) · 5.45 KB
/
analyzeContourPointsDistances.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
function [distancePointsExternalContourPieces, distancePointsInternalContourPieces]=analyzeContourPointsDistances(pStructProcessGenericPieceReference, pStructProcessGenericPieceOne)
distancePointsExternalContourPieces=infinites(360, 1);
distancePointsInternalContourPieces=infinites(360, 1);
if (isempty(pStructProcessGenericPieceReference)==1)||(isempty(pStructProcessGenericPieceOne)==1)
warndlg('Input argument (process generic pieces) is empty.', ' Warning ');
return;
end
infoPointsExternalContourPieceReference=pStructProcessGenericPieceReference.InfoPointsExternalContour;
infoPointsInternalContourPieceReference=pStructProcessGenericPieceReference.InfoPointsInternalContour;
infoAngleSlotPieceReference=pStructProcessGenericPieceReference.InfoAngleSlot;
infoPointsExternalContourPieceOne=pStructProcessGenericPieceOne.InfoPointsExternalContour;
infoPointsInternalContourPieceOne=pStructProcessGenericPieceOne.InfoPointsInternalContour;
infoAngleSlotPieceOne=pStructProcessGenericPieceOne.InfoAngleSlot;
%Based on axis of symmetry of the part
angleSlotMeanPieceReference=mean(infoAngleSlotPieceReference,2);
angleSlotMeanComplementaryPieceReference=round(mod(angleSlotMeanPieceReference+180,360));
angleSlotMeanPieceOne=mean(infoAngleSlotPieceOne,2);
angleSlotMeanComplementaryPieceOne=round(mod(angleSlotMeanPieceOne+180,360));
iPieceReference=angleSlotMeanComplementaryPieceReference;
iPieceOne=angleSlotMeanComplementaryPieceOne;
angleSlotEndPieceReference=infoAngleSlotPieceReference(2)-1;
if (angleSlotEndPieceReference==0) angleSlotEndPieceReference=360; end
angleSlotEndPieceOne=infoAngleSlotPieceOne(2);
if (angleSlotEndPieceOne==0) angleSlotEndPieceOne=360; end
angleSlotStartPieceReference=mod(infoAngleSlotPieceReference(1)+1,360);
angleSlotStartPieceOne=mod(infoAngleSlotPieceOne(1)+1,360);
%From mean complementary angle to end angle (piece reference and piece one)
while (iPieceReference~=angleSlotEndPieceReference)&&(iPieceOne~=angleSlotEndPieceOne)
distancePointsExternalContourPieces(iPieceReference,1)=infoPointsExternalContourPieceReference(iPieceReference,3)-infoPointsExternalContourPieceOne(iPieceOne,3);
distancePointsInternalContourPieces(iPieceReference,1)=infoPointsInternalContourPieceReference(iPieceReference,3)-infoPointsInternalContourPieceOne(iPieceOne,3);
iPieceReference=iPieceReference-1;
if (iPieceReference==0) iPieceReference=360; end
iPieceOne=iPieceOne-1;
if (iPieceOne==0) iPieceOne=360; end
end
if (iPieceReference~=angleSlotEndPieceReference)
while (iPieceOne~=angleSlotEndPieceOne)
distancePointsExternalContourPieces(iPieceReference,1)=infoPointsExternalContourPieceOne(iPieceOne,3)+100;
distancePointsInternalContourPieces(iPieceReference,1)=infoPointsInternalContourPieceOne(iPieceOne,3)+100;
iPieceReference=iPieceReference-1;
if (iPieceReference==0) iPieceReference=360; end
iPieceOne=iPieceOne-1;
if (iPieceOne==0) iPieceOne=360; end
end
else %(iPieceOne==angleSlotEndPieceOne)
while (iPieceReference~=angleSlotEndPieceReference)
distancePointsExternalContourPieces(iPieceReference,1)=-infoPointsExternalContourPieceReference(iPieceReference,3)-100;
distancePointsInternalContourPieces(iPieceReference,1)=-infoPointsInternalContourPieceReference(iPieceReference,3)-100;
iPieceReference=iPieceReference-1;
if (iPieceReference==0) iPieceReference=360; end
end
end
%From mean complementary angle to start angle (piece reference and piece one)
iPieceReference=angleSlotMeanComplementaryPieceReference;
iPieceOne=angleSlotMeanComplementaryPieceOne;
while (iPieceReference~=angleSlotStartPieceReference)&&(iPieceOne~=angleSlotStartPieceOne)
distancePointsExternalContourPieces(iPieceReference,1)=infoPointsExternalContourPieceReference(iPieceReference,3)-infoPointsExternalContourPieceOne(iPieceOne,3);
distancePointsInternalContourPieces(iPieceReference,1)=infoPointsInternalContourPieceReference(iPieceReference,3)-infoPointsInternalContourPieceOne(iPieceOne,3);
iPieceReference=mod(iPieceReference,360)+1;
iPieceOne=mod(iPieceOne,360)+1;
end
if (iPieceReference==angleSlotStartPieceReference)
while (iPieceOne~=angleSlotStartPieceOne)
distancePointsExternalContourPieces(iPieceReference,1)=infoPointsExternalContourPieceOne(iPieceOne,3)+100;
distancePointsInternalContourPieces(iPieceReference,1)=infoPointsInternalContourPieceOne(iPieceOne,3)+100;
iPieceReference=mod(iPieceReference,360)+1;
iPieceOne=mod(iPieceOne,360)+1;
end
else %(iPieceOne==angleSlotStartPieceOne)
while (iPieceReference~=angleSlotStartPieceReference)
distancePointsExternalContourPieces(iPieceReference,1)=-infoPointsExternalContourPieceReference(iPieceReference,3)-100;
distancePointsInternalContourPieces(iPieceReference,1)=-infoPointsInternalContourPieceReference(iPieceReference,3)-100;
iPieceReference=mod(iPieceReference,360)+1;
end
end
end