-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgeneratePointSetsForCAD.m
More file actions
249 lines (129 loc) · 4.89 KB
/
generatePointSetsForCAD.m
File metadata and controls
249 lines (129 loc) · 4.89 KB
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
% This script generates xyz points in a .sldcrv file that will form the
% outline of the wing, rudder and horizontal stabilizer.
%% Wing End 1 file
basePath = fullfile(fileparts(fileparts(which('OCKModel.slx'))),'CAD');
wingFileName = 'wing1Orig.sldcrv';
wing1 = load(wingFileName);
newFileName = 'wing1.sldcrv';
fileID = fopen(newFileName,'w');
% [wingX,wingZ]=load(plant.wingShapeFileName);
% Scale to appropriate size
scaleFactor = 0.015;
wingX = wing1(:,1)*scaleFactor;
wingY = wing1(:,2)*scaleFactor;
wingZ = wing1(:,3)*scaleFactor;
% Convert to in
% wingX = -39.3701*wingX; % Flip the x coordinate so that the leading edge is pointed towards +x dir
%
% wingY = 39.3701*wingY;
%
% wingZ = 39.3701*wingZ;
% fileID = fopen('exp.txt','w');
fprintf(fileID,'%.4fm %.4fm %.4fm\r\n',[wingX';wingY';wingZ']);
% fclose(fileID);
fclose('all');
%% Wing End 2 file
basePath = fullfile(fileparts(fileparts(which('OCKModel.slx'))),'CAD');
wingFileName = 'wing2Orig.sldcrv';
wing2 = load(wingFileName);
newFileName = 'wing2.sldcrv';
fileID = fopen(newFileName,'w');
% Scale to appropriate size
wingX = wing2(:,1)*scaleFactor;
wingY = wing2(:,2)*scaleFactor;
wingZ = wing2(:,3)*scaleFactor;
% Convert to m
wingX = 0.0254*wingX; % Flip the x coordinate so that the leading edge is pointed towards +x dir
wingY = 0.0254*wingY;
wingZ = 0.0254*wingZ;
% fileID = fopen('exp.txt','w');
fprintf(fileID,'%.4fm %.4fm %.4fm\r\n',[wingX';wingY';wingZ']);
% fclose(fileID);
fclose('all');
%% Rudder Tip File
rudderTipScaleFactor = 0.75;
basePath = fullfile(fileparts(fileparts(which('OCKModel.slx'))),'CAD');
rudderFileName = 'rudderTipOrig.sldcrv';
rudderTip = load(rudderFileName);
newFileName = 'rudderTip.sldcrv';
fileID = fopen(newFileName,'w');
% Flip and shift so that it goes in -x direction
% Scale to appropriate size
rudderXt = rudderTip(:,1)*scaleFactor;
rudderYt = rudderTip(:,2)*scaleFactor;
rudderZt = rudderTip(:,3)*scaleFactor;
%Increase length
rudderXt = rudderXt*2 - rudderXt(1) - .25;
% Convert to in
rudderXt = 0.0254*rudderXt;
rudderYt = 0.0254*rudderYt;
rudderZt = 0.0254*rudderZt;
% fileID = fopen('exp.txt','w');
fprintf(fileID,'%.6fm %.6fm %.6fm\r\n',[rudderXt';rudderYt';rudderZt']);
% fclose(fileID);
fclose('all');
%% Rudder Base File
rudderBaseScaleFactor = 1.75;
basePath = fullfile(fileparts(fileparts(which('OCKModel.slx'))),'CAD');
rudderFileName = 'rudderBaseOrig.sldcrv';
rudderBase = load(rudderFileName);
newFileName = 'rudderBase.sldcrv';
fileID = fopen(newFileName,'w');
% Flip and shift so that it goes in -x direction
% Scale to appropriate size
rudderXb = rudderBase(:,1)*scaleFactor;
rudderYb = rudderBase(:,2)*scaleFactor;
rudderZb = rudderBase(:,3)*scaleFactor;
%Increase length
rudderXb = rudderXb*1.85 - rudderXb(1)*.85;
% Move backwards
% Convert to in
rudderXb = 0.0254*rudderXb;
rudderYb = 0.0254*rudderYb;
rudderZb = 0.0254*rudderZb;
% fileID = fopen('exp.txt','w');
fprintf(fileID,'%.6fm %.6fm %.6fm\r\n',[rudderXb';rudderYb';rudderZb']);
% fclose(fileID);
fclose('all');
%% Stabilizer Tip 1
basePath = fullfile(fileparts(fileparts(which('OCKModel.slx'))),'CAD');
stabilizerFileName = 'stabilizerTip1Orig.sldcrv';
stabilizer = load(stabilizerFileName);
newFileName = 'stabilizerTip1.sldcrv';
fileID = fopen(newFileName,'w');
% Scale to appropriate size
stabilizerX1 = stabilizer(:,1)*scaleFactor;
stabilizerY1 = stabilizer(:,2)*scaleFactor;
stabilizerZ1 = stabilizer(:,3)*scaleFactor;
%Double distance from zero and increase chord length
stabilizerX1 = stabilizerX1*2 - stabilizerX1(1);
stabilizerY1 = stabilizerY1*2;
% Convert to in
stabilizerX1 = 0.0254*stabilizerX1;
stabilizerY1 = 0.0254*stabilizerY1;
stabilizerZ1 = 0.0254*stabilizerZ1;
% Move backwards
% fileID = fopen('exp.txt','w');
fprintf(fileID,'%.6fm %.6fm %.6fm\r\n',[stabilizerX1';stabilizerY1';stabilizerZ1']);
fclose('all');
%% Stabilizer Tip 2
basePath = fullfile(fileparts(fileparts(which('OCKModel.slx'))),'CAD');
stabilizerFileName = 'stabilizerTip2Orig.sldcrv';
newFileName = 'stabilizerTip2.sldcrv';
fileID = fopen(newFileName,'w');
stabilizer = load(stabilizerFileName);
% Scale to appropriate size
stabilizerX2 = stabilizer(:,1)*scaleFactor;
stabilizerY2 = stabilizer(:,2)*scaleFactor;
stabilizerZ2 = stabilizer(:,3)*scaleFactor;
%Double distance from zero and increase chord length
stabilizerX2 = stabilizerX2*2 - stabilizerX2(1);
stabilizerY2 = stabilizerY2*2;
% Convert to in
stabilizerX2 = 0.0254*stabilizerX2;
stabilizerY2 = 0.0254*stabilizerY2;
stabilizerZ2 = 0.0254*stabilizerZ2;
% Move backwards
% fileID = fopen('exp.txt','w');
fprintf(fileID,'%.6fm %.6fm %.6fm\r\n',[stabilizerX2';stabilizerY2';stabilizerZ2']);
fclose('all');