! ******************* aircraft******************************* ! +++ ! ! Creation of aircraft surfaces ! ! --- ! ! ! Revision history ! _______________ ! ! Copyright 1997-05-06 Gunnar Liden, All Rights Reserved ! ! Released under the MIT License: ! ! Permission is hereby granted, free of charge, to any person ! obtaining a copy of this software and associated documentation ! files (the "Software"), to deal in the Software without ! restriction, including without limitation the rights to use, ! copy, modify, merge, publish, distribute, sublicense, and/or sell ! copies of the Software, and to permit persons to whom the ! Software is furnished to do so, subject to the following ! conditions: ! ! The above copyright notice and this permission notice shall be ! included in all copies or substantial portions of the Software. ! ! THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ! EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES ! OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ! NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT ! HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, ! WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING ! FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR ! OTHER DEALINGS IN THE SOFTWARE. ! ! ************************************************************ !sdesce Creation of aircraft surfaces !sdescs Skapa flygplansytor GLOBAL GEOMETRY MODULE aircraft ( REF pla_id >"@t16384 Select plane shape"; REF pro_id >"@t16384 Select profile"; REF sca_id >"@t16384 Select Z scale curve"; STRING s_d*30 := "AC X" >"Name / description"; INT graphic:= 1 >"=0: Show nothing =1: Aircraft =2: All"); ! Internal variables INT n_sect; ! Number of sections for fuselage INT i_sect; ! Loop index section FLOAT y_delta; ! Delta Y section value FLOAT y_sect; ! Current Y section value INT n_poi; ! Number of points (patches) INT i_poi; ! Loop index point in curve FLOAT a1_poi; ! Delta arclength for point FLOAT a2_poi; ! Delta arclength for nose points FLOAT t_arc; ! Total arclength for curve VECTOR p_cur; ! Point on the curve VECTOR t_cur; ! Tangent for pt on the curve VECTOR c_cur; ! Cross slope for pt on the curve FLOAT u_arc; ! Current arclength for point FLOAT u_poi; ! Parameter for current arclength REF pcur_id; ! Profile curve # identity REF prot_id; ! Rotated profile curve # identity REF scur_id; ! Scale curve # identity REF lead_id; ! Leading curve # identity REF trail_id; ! Trailing curve # identity VECTOR p_sca; ! Scaling (intersect) point FLOAT z_scale; ! Scale factor VECTOR p_lead; ! Leading (intersect) point VECTOR p_trail; ! Trailing (intersect) point FLOAT chord; ! Chord length ! Attributes for plashape: FLOAT x_1; ! 1 Forward fuselage nose point X FLOAT pv1; ! 2 P-value forward fuselage FLOAT x_2; ! 3 Forward fuselage end point X FLOAT y_2; ! 4 Forward fuselage end point Y FLOAT x_3; ! 5 Wing leading edge start point X FLOAT y_3; ! 6 Wing Start station value Y FLOAT x_4; ! 7 Wing leading edge outer point X FLOAT y_4; ! 8 Wing end station value Y FLOAT x_5; ! 9 Wing trailing edge outer point X FLOAT x_6; ! 10 Wing trailing edge inner point X FLOAT x_7; ! 11 Rear fuselage end point X FLOAT y_7; ! 12 Rear fuselage end point Y ! For GTGRP REF group_id; ! Reference to group STRING group_name*10;! Group name INT n_member; ! Number of members in group REF member_id(3); ! References to the members ! For SUR_SPLARR VECTOR poi( 60,11); ! Points VECTOR tanu( 60,11); ! U tangents STRING metod*15; ! Method for tangent length calculation ! ZEROTWIST_1 or ADINI_1 INT b_val_s; ! Blank value for output surfaces INT b_val_a; ! Blank value all other entities BEGINMODULE ! +++ ! Algorithm ! _________ ! --- ! +++ ! 1. Checks and initializations ! --- ! +++ ! Check graphic variable ! --- IF graphic = 0 THEN b_val_s := 1; b_val_a := 1; ELIF graphic = 1 THEN b_val_s := 0; b_val_a := 1; ELIF graphic = 2 THEN b_val_s := 0; b_val_a := 0; ELSE EXIT("aircraft graphic is not 0, 1 or 2"); ENDIF; ! +++ ! 2. Determine section values and retrieve references ! --- ! +++ ! Retrieve Y values from the projected shape ! --- y_2 := GETFLT(pla_id, 4); y_3 := GETFLT(pla_id, 6); y_4 := GETFLT(pla_id, 8); ! +++ ! Let nsect= 8 for the fuselage and calculate delta Y value ! Let n_poi= 60 ! --- n_sect := 8; y_delta := y_3/(n_sect-1); n_poi := 60; ! +++ ! Get reference to the profile curve ! --- SET_ROOT_GM(pro_id); group_id := GET_NEXT_GM(0, 4096, "Profile"); IF group_id = #0 THEN EXIT("aircraft There is no (GROUP) Profile in "+RSTR(pro_id)); ENDIF; GETGRP(group_id, group_name, n_member, member_id); pcur_id := member_id(1); ! +++ ! Get reference to the leading and trailing edge ! --- SET_ROOT_GM(pla_id); group_id := GET_NEXT_GM(0, 4096, "L_E"); IF group_id = #0 THEN EXIT("aircraft There is no (GROUP) L_E in "+RSTR(pla_id)); ENDIF; GETGRP(group_id, group_name, n_member, member_id); lead_id := member_id(1); SET_ROOT_GM(pla_id); group_id := GET_NEXT_GM(0, 4096, "T_E"); IF group_id = #0 THEN EXIT("aircraft There is no (GROUP) T_E in "+RSTR(pla_id)); ENDIF; GETGRP(group_id, group_name, n_member, member_id); trail_id := member_id(1); ! +++ ! Get reference to the Z scale curve ! --- SET_ROOT_GM(sca_id); group_id := GET_NEXT_GM(0, 4096, "Zscale"); IF group_id = #0 THEN EXIT("aircraft There is no (GROUP) Zscale in "+RSTR(sca_id)); ENDIF; GETGRP(group_id, group_name, n_member, member_id); scur_id := member_id(1); ! +++ ! Rotate the profile curve ! --- TFORM_ROTL(#11, VEC(0,0,0),VEC(1000,0,0), -90.0); TCOPY(#12, pcur_id, GLOBAL_REF(#11),1:BLANK=b_val_a,PEN=5); prot_id := GLOBAL_REF(#12); ! +++ ! 3. Calculate section curves and put data in surface arrays ! --- ! +++ ! Start loop sections in the fuselage i_sect= 1,2,3, .. , n_sect+1 ! --- FOR i_sect := 1 TO n_sect + 1 DO ! +++ ! Current Y section value y_sect = (i_sect-1)*y_delta ! except for last value wich is y_sect = y_4 ! --- IF i_sect <= n_sect THEN y_sect := (i_sect-1)*y_delta; ELSE y_sect := y_4 - 0.02; ENDIF; ! +++ ! Calculate Z scaling factor for the profile ! --- B_PLANE(#21, VEC(y_sect,0,0), VEC(y_sect,2,2), VEC(y_sect,2,2), VEC(y_sect,4,0): BLANK=b_val_a); p_sca := INTERSECT(scur_id, GLOBAL_REF(#21), 1); DEL(GLOBAL_REF(#21)); z_scale := p_sca.y; ! +++ ! Calculate chord length and translation coeffient ! --- B_PLANE(#22, VEC( 0,y_sect, 0), VEC(100,y_sect,200), VEC(100,y_sect,200), VEC( 0,y_sect,400): BLANK=b_val_a); p_lead := INTERSECT(lead_id, GLOBAL_REF(#22), 1); p_trail:= INTERSECT(trail_id, GLOBAL_REF(#22), 1); DEL(GLOBAL_REF(#22)); chord := VECL(p_trail-p_lead); ! +++ ! Create transformation matrix for the profile and copy profile ! --- TFORM_MOVE(#23, VEC(0,0,0), p_lead, chord/1000.0, 1, z_scale); TCOPY(#2, prot_id, GLOBAL_REF(#23),1:BLANK=b_val_a,PEN=3); DEL(GLOBAL_REF(#23)); ! +++ ! Calculate delta arclength for points on curve ! --- t_arc := ARCL(GLOBAL_REF(#2)); a1_poi := (t_arc-0.10*t_arc)/(n_poi-22); a2_poi := 0.10*t_arc/21; u_arc := -a1_poi; ! +++ ! Calculate points on the profile curve ! Start loop i_poi:= 1, 2, .., n_poi ! --- FOR i_poi := 1 TO n_poi DO ! +++ ! Current arclength for point u_arc ! --- IF i_poi >= n_poi/2-10 AND i_poi <= n_poi/2+10 THEN u_arc := u_arc + a2_poi; ELSE u_arc := u_arc + a1_poi; ENDIF; ! +++ ! Calculate U parameter for current arclength ! --- u_poi := INV_ARCL(GLOBAL_REF(#2), u_arc); ! +++ ! Calculate point and tangent ! --- p_cur := ON(GLOBAL_REF(#2), u_poi); t_cur := TANG(GLOBAL_REF(#2), u_poi); IF i_sect = 1 THEN c_cur := VEC(0,1,0); ELSE c_cur := VEC(0,0,0); ENDIF; ! +++ ! Calculated point data to surface arrays ! --- poi (i_poi,i_sect) := p_cur; tanu(i_poi,i_sect) := t_cur; ! +++ ! End loop points on the profile curve ! --- ENDFOR; DEL(GLOBAL_REF(#2)); ! +++ ! End loop sections in the fuselage ! --- ENDFOR; ! +++ ! 4. Create fuselage and wing surfaces ! --- ! +++ ! Left fuselage ! --- metod := "ZEROTWIST_1"; SUR_SPLARR(#1,metod,n_poi, n_sect,poi,tanu:BLANK=b_val_s); FOR i_poi := 1 TO n_poi DO poi(i_poi,1) := poi(i_poi, n_sect ); tanu(i_poi,1) := tanu(i_poi, n_sect ); poi(i_poi,2) := poi(i_poi, n_sect+1); tanu(i_poi,2) := tanu(i_poi, n_sect+1); ENDFOR; ! +++ ! Left wing ! --- SUR_SPLARR(#3,metod,n_poi, 2 ,poi,tanu:BLANK=b_val_s); ! +++ ! Right fuselage and wing ! --- TFORM_MIRR (#26, VEC(0,0,0), VEC(1,0,1), VEC(2,0,0)); TCOPY(#27,GLOBAL_REF(#1), GLOBAL_REF(#26), 1:BLANK=b_val_a,PEN=3); TCOPY(#28,GLOBAL_REF(#3), GLOBAL_REF(#26), 1:BLANK=b_val_a,PEN=2); SUR_TRIM(#33, GLOBAL_REF(#27), n_poi-1, 0, 0, n_sect-1: BLANK=b_val_s); SUR_TRIM(#34, GLOBAL_REF(#28), n_poi-1, 0, 0, 1: BLANK=b_val_s); ENDMODULE