! ******************* canopy ******************************* ! +++ ! ! Definition of the canopy for the aircraft ! ! --- ! ! ! 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 Definition of the canopy for the aircraft !sdescs Definition av huv GLOBAL GEOMETRY MODULE canopy ( REF air_id >"@t16384 Select aircraft"; FLOAT s_r := 0.1 >"Relative start position for canopy (0-1)"; FLOAT l_c := 6000.00 >"Length of canopy"; FLOAT w_c := 700.00 >"Width of canopy"; FLOAT h_c := 1000.00 >"Heigth of canopy"; INT graphic:= 1 >"=0: Show nothing =1: Canopy =2: All"); ! Internal variables VECTOR p_cs; ! Start position canopy for top curve VECTOR p_cm; ! Mid position canopy for top curve VECTOR p_ce; ! End position canopy for top curve VECTOR p_ms; ! Start position canopy for maxw. curve VECTOR p_mm; ! Mid position canopy for maxw. curve VECTOR p_me; ! End position canopy for maxw. curve REF pla_id; ! Reference to pla_id ! 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 FLOAT z_c; ! 13 Z value for the plane shape FLOAT eps; ! Epsilon for safe intersects REF spine_id; ! Identity for spine REF lim1_id; ! Identity for limit 1 curve REF lim2_id; ! Identity for limit 2 curve REF lim3_id; ! Identity for limit 3 curve REF tan1_id; ! Identity for tangent 1 curve REF tan2_id; ! Identity for tangent 2 curve REF tan3_id; ! Identity for tangent 3 curve REF pval_id; ! Identity for P-value function FLOAT a_spine; ! Spine arclength 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 PART(#51, inp_err (VEC(3000,0,0))); EXIT("canopy graphic is not 0, 1 or 2"); ENDIF; ! +++ ! Check relative X start position ! --- IF s_r < 0.0 + 0.01 OR s_r > 1.0 - 0.01 THEN PART(#52, inp_err (VEC(3000,0,0))); EXIT("canopy Relative X position not between 0 and 1 "); ENDIF; ! +++ ! Retrieve data from the projected shape ! --- pla_id := GETREF(air_id, 1); x_1 := GETFLT(pla_id, 1); x_2 := GETFLT(pla_id, 3); x_3 := GETFLT(pla_id, 5); x_4 := GETFLT(pla_id, 7); x_5 := GETFLT(pla_id, 9); x_6 := GETFLT(pla_id,10); x_7 := GETFLT(pla_id,11); z_c := GETFLT(pla_id,13); ! +++ ! Check dimensions of canopy ! --- ! Check relative to size of aircraft IF l_c < 0.2*(x_3-x_2) THEN PART(#53, inp_err (VEC(3000,0,0))); EXIT("canopy Canopy length < "+STR(0.2*(x_3-x_2),-10,2)); ENDIF; IF w_c > 0.5*l_c THEN PART(#54, inp_err (VEC(3000,0,0))); EXIT("canopy Canopy width > 0.5*length= "+STR(0.5*l_c,-10,2)); ENDIF; IF w_c < 0.05*l_c THEN PART(#55, inp_err (VEC(3000,0,0))); EXIT("canopy Canopy width < 0.05*length= "+STR(0.05*l_c,-10,2)); ENDIF; IF h_c > 0.7*l_c THEN PART(#56, inp_err (VEC(3000,0,0))); EXIT("canopy Canopy height > 0.7*length= "+STR(0.7*l_c,-10,2)); ENDIF; IF h_c < 0.07*l_c THEN PART(#57, inp_err (VEC(3000,0,0))); EXIT("canopy Canopy height < 0.07*length= "+STR(0.07*l_c,-10,2)); ENDIF; ! +++ ! 2. Calculate start and end position for canopy and outlet ! --- ! p_cs := VEC(x_2+s_r*(x_3-x_2), 0.0, z_c - 0.4*h_c); ! p_ce := p_cs + VEC(l_c, 0.0, 0.0); ! p_cm := p_cs + VEC(0.3*l_c, 0.0, - h_c); ! p_ms := VEC(x_2+s_r*(x_3-x_2), 0.02*(x_3-x_2), z_c ); ! p_me := p_ms + VEC(l_c, 0.0, 0.0); ! p_mm := p_ms + VEC(0.3*l_c, w_c , 0.0); p_cs := VEC(x_1+s_r*(x_3-x_1), 0.0, z_c - 0.4*h_c); p_ce := p_cs + VEC(l_c, 0.0, 0.0); p_cm := p_cs + VEC(0.3*l_c, 0.0, - h_c); p_ms := VEC(x_1+s_r*(x_3-x_1), 0.02*(x_3-x_2), z_c ); p_me := p_ms + VEC(l_c, 0.0, 0.0); p_mm := p_ms + VEC(0.3*l_c, w_c , 0.0); POI_FREE(#20,p_cs:BLANK=b_val_a,PEN=2); POI_FREE(#21,p_ce:BLANK=b_val_a,PEN=2); POI_FREE(#22,p_cm:BLANK=b_val_a,PEN=2); POI_FREE(#23,p_ms:BLANK=b_val_a,PEN=4); POI_FREE(#24,p_me:BLANK=b_val_a,PEN=4); POI_FREE(#25,p_mm:BLANK=b_val_a,PEN=4); ! +++ ! 3. Create spine, top curve and maximum width curves ! --- eps := 0.01; CUR_CONIC(#3, "FREE", p_cs+VEC(eps,0,0), p_ce, 0.5, p_ce-VEC(eps,0,0), p_cs :BLANK=b_val_a,PEN=3); spine_id := GLOBAL_REF(#3); ! Weakness in coloured shading functions CUR_TRIM(#41, spine_id, 0.0, 0.7:BLANK=b_val_a,PEN=1); CUR_TRIM(#42, spine_id, 0.7, 0.8:BLANK=b_val_a,PEN=1); CUR_TRIM(#43, spine_id, 0.8, 0.9:BLANK=b_val_a,PEN=1); CUR_TRIM(#44, spine_id, 0.9, 1.0:BLANK=b_val_a,PEN=1); CUR_COMP(#47, GLOBAL_REF(#41),GLOBAL_REF(#42), GLOBAL_REF(#43),GLOBAL_REF(#44) :BLANK=b_val_a,PEN=1); spine_id := GLOBAL_REF(#47); CUR_CONIC(#4, "FREE", p_cs, p_cm+VEC(0.2*(p_cs.x-p_cm.x),0,0), 0.6, p_cm, p_cm+VEC(1,0,0), 0.5, p_ce, p_ce+VEC(1,0,4) :BLANK=b_val_a,PEN=2); lim2_id := GLOBAL_REF(#4); CUR_CONIC(#5, "FREE", p_ms, p_mm+VEC(0.2*(p_ms.x-p_mm.x),0,0), 0.6, p_mm, p_mm+VEC(1, 0,0), 0.5, p_me, p_me+VEC(1,-1,0) :BLANK=b_val_a,PEN=4); lim1_id := GLOBAL_REF(#5); TFORM_MIRR(#16, VEC(0,0,0), VEC(1,0,1), VEC(2,0,0)); TCOPY(#17, lim1_id, GLOBAL_REF(#16), 1 :BLANK=b_val_a,PEN=4); lim3_id := GLOBAL_REF(#17); ! +++ ! 4. Create tangent definition curves (TFORM_MOVE and TFORM_COPY) ! --- TFORM_MOVE(#7, VEC(0,0,0), VEC(0, 0.2*w_c, 0.0 )); TFORM_MOVE(#8, VEC(0,0,0), VEC(0, 0.0, 0.2*w_c)); TCOPY(#9 , lim1_id, GLOBAL_REF(#8), 1 :BLANK=b_val_a,PEN=3); tan1_id := GLOBAL_REF(#9 ); TCOPY(#10, lim2_id, GLOBAL_REF(#7), 1 :BLANK=b_val_a,PEN=3); tan2_id := GLOBAL_REF(#10); TCOPY(#11, lim3_id, GLOBAL_REF(#8), 1 :BLANK=b_val_a,PEN=3); tan3_id := GLOBAL_REF(#11); ! +++ ! 5. Create P-value function ! --- a_spine := ARCL(spine_id); MODE_BASIC(); CUR_CONIC(#12, "FREE", VEC( 0, 0.6, 0), VEC(a_spine,0.4 ,0), 0.5, VEC(a_spine,0.4, 0), VEC( 0, 0.6, 0) :BLANK=b_val_a,PEN=1); pval_id := GLOBAL_REF(#12); MODE_GLOBAL(); ! +++ ! 6. Create the surface (function SUR_CONIC) ! --- SUR_CONIC(#1, spine_id, lim3_id, tan3_id, "P", pval_id, lim2_id, tan2_id, "P", pval_id, lim1_id, tan1_id :BLANK=b_val_s); ENDMODULE