!****h* NGB/Control ! NAME ! Control -- Varkon user interface module to locate ! and edit the control points on each X-Section of the NGB model ! [Control.MBS] ! ! DESCRIPTION ! This module may be pasted into the interactive active ! module of VARKON under the NGB project files directory. ! This permits interactive adjustment of the ! control points which alter the watercrafts ! hull surface. The module's content is described in ! the following lists of steps. ! ! Declare the following Variables and Constants: ! * L - This a parametric value used to control the length of ! the watercraft ! * Pt - This is an array used to transfer all edited points to the ! Main() module ! which plots and evaluates the glideboat. ! * Blanking variables (CrdBlnk, etc) - These control which points ! are visible for editing ! * Array Indices - Constants used to name the rows of the ! 'Pt' array which are transferred to the 'Main() module for use. ! ! Steps Taken: ! * Generate the Keel Board Edge from a series of parametric 'L' based ! values. ! All of the Cross-Section curves begin from the edge of this board. ! The parametric values establish the 'rocker' curve for the keel. ! * Set up Blanking values for each set of section control points. These ! values are manually edited to select one section for editing. ! * Locate and declare the coordinate system for each section's control ! points. ! * Initialize coordinates for all 36 X-Section control points ! (6 Sections w/6 points each). These values may be edited interactively. ! ! The point coordinates can all be edited manually 6 nodes at a time (blank ! all others). The editing can be done interactively using the 'xy' view ! and moving the points for any of the unblanked 6 nodes. Any node ! adjustment made will be propogated through the entire model. The model ! must be executed with the 'RUN' button in the main window after editing. ! ! Copyright 2006, John J. Hughes (Email: n4yvt@arrl.net) ! ! GNU General Public License ! ! This source code file is part of the 'NGB' project files which ! execute interactively under the 'Varkon' program, which is ! distributed under the terms of the GNU General Public License. ! ! The 'NGB' project files are also distributed under the terms of ! the GNU GeneralPublic License. See the GNU General Public License n ! included ithe file name "COPYING.txt" in the Varkon ./app/NGB/doc ! directory for more details. ! ! NGB is free software; you can redistribute it and/or modify ! it under the terms of the GNU General Public License as published by ! the Free Software Foundation; either version 2 of the License, or ! (at your option) any later version. ! ! NGB is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License included in the file name "COPYING.txt". ! ! You should have received a copy of the GNU General Public License ! along with NGB; if not, write to the Free Software Foundation, ! Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ! ! SOURCE GLOBAL GEOMETRY MODULE Control( FLOAT L:=192.0); ! Parameter to control length of watercraft !*** INT CrdBlnk,StrnBlnk,AftBlnk,MidBlnk,ForeBlnk,Bow_XBlnk, Bow_CRVBlnk,KeelBdBlnk,i, NoPts; CONSTANT INT Coord=0, Stern=1, Aft=2, Mid=3, Fore=4, Bow_X=5, Bow_CRV=6, KeelBoard=7; VECTOR Pt(0:7,0:6),CrvPts(13); FLOAT PValues(13),tmp1,tmp2,tmp3; BEGINMODULE set_basic(Pen=10,LEVEL=0,LFONT=0); unblank_lev(0); !*********************************************************************** ! ~ Blanking variable initialization !----------------------------------------------------------------------- CrdBlnk:=1; StrnBlnk:=1; AftBlnk:=1; MidBlnk:=1; ForeBlnk:=1; Bow_XBlnk:=1; Bow_CRVBlnk:=1; KeelBdBlnk:=1; !*********************************************************************** ! ~ Coordinate System Location Points !----------------------------------------------------------------------- poi_free(#10,vec(0, 0, 0):BLANK=CrdBlnk); poi_free(#20,vec(0, 0, 2*L/11):BLANK=CrdBlnk); poi_free(#30,vec(0, 0, L/2):BLANK=CrdBlnk); poi_free(#40,vec(0, 0, 9*L/11):BLANK=CrdBlnk); poi_free(#50,vec(0, 0, 18*L/19):BLANK=CrdBlnk); poi_free(#55,vec(0, 0, 18*L/19):BLANK=CrdBlnk); !*********************************************************************** ! ~ Coordinate System Declaration !----------------------------------------------------------------------- csys_1p(#70,"STERN", on(#10), 0.0, 0.0, 0.0:BLANK=StrnBlnk); csys_1p(#80,"AFT", on(#20), 0.0, 0.0, 0.0:BLANK=AftBlnk); csys_1p(#90,"MID", on(#30), 0.0, 0.0, 0.0:BLANK=MidBlnk); csys_1p(#100,"FORE", on(#40), 0.0, 0.0, 0.0:BLANK=ForeBlnk); csys_1p(#110,"BOW-X", on(#50), 0.0, 0.0, 0.0:BLANK=Bow_XBlnk); csys_1p(#120,"BOW-CRV", on(#55), 0.0, 270, 0:BLANK=Bow_CRVBlnk); !*********************************************************************** ! ~ Keelboard Edge Points in Basic coordinate system !----------------------------------------------------------------------- Pt(KeelBoard, 0):=vec(L/75, L/180-2.5-0.0*L, 0); Pt(KeelBoard, 1):=vec(L/65, L/180-2.5-0.003078*L, 2*L/11); Pt(KeelBoard, 2):=vec(L/59, L/180-2.5-0.0049384*L, L/3); Pt(KeelBoard, 3):=vec(L/59, L/180-2.5-0.0055555*L, L/2); Pt(KeelBoard, 4):=vec(L/60, L/180-2.5-0.0049384*L, L - L/3); Pt(KeelBoard, 5):=vec(L/85, L/180-2.5-0.003078*L, 9*L/11); Pt(KeelBoard, 6):=vec(L/431, L/180-2.5-0.0*L, 18*L/19); !*********************************************************************** ! ~ Keel board edge curve for connection to connect X-section ! ~ Bezier curves !----------------------------------------------------------------------- CrvPts(1):=Pt(KeelBoard,0); CrvPts(2):=Pt(KeelBoard,1); CrvPts(3):=Pt(KeelBoard,3); CrvPts(4):=Pt(KeelBoard,5); CrvPts(5):=Pt(KeelBoard,6); NoPts:= 5; part(#135,PInit(NoPts,0.0,0.5,0.0,PValues)); part(#140, CubicCrv(NoPts,PValues,CrvPts):BLANK=KeelBdBlnk); !*********************************************************************** ! ~ Stern Control Points !----------------------------------------------------------------------- mode_global(); poi_free(#150,CrvPts(1):BLANK=StrnBlnk); mode_local(#70); poi_free(#160,vec(2.7740888637219, -0.8164533820841, 0.0):BLANK=StrnBlnk); poi_free(#170,vec(2.4147786469725, 2.994660655261, 0.0):BLANK=StrnBlnk); poi_free(#180,vec(4.7063489054917, 10.256164043209, 0.0):BLANK=StrnBlnk); poi_free(#190,vec(5.981206747439, 15.052645161888, 0.0):BLANK=StrnBlnk); poi_free(#200,vec(5.8312841089899, 22.117787662804, 0.0):BLANK=StrnBlnk); !*********************************************************************** ! ~ Aft Section Control Points !----------------------------------------------------------------------- mode_global(); poi_free(#280,CrvPts(2):BLANK=AftBlnk); mode_local(#80); poi_free(#290,vec(5.4724682408416, -1.7180450369306, 0.0):BLANK=AftBlnk); poi_free(#300,vec(3.3918489309835, 4.3452492043058, 0.0):BLANK=AftBlnk); poi_free(#310,vec(11.409234189841, 6.1163882185297, 0.0):BLANK=AftBlnk); poi_free(#320,vec(13.932917243067, 12.058401720804, 0.0):BLANK=AftBlnk); poi_free(#330,vec(14.480324887262, 17.96629505182, 0.0):BLANK=AftBlnk); !*********************************************************************** ! ~ Mid Section Control Points !----------------------------------------------------------------------- mode_global(); poi_free(#350,CrvPts(3):BLANK=MidBlnk); mode_local(#90); poi_free(#360,vec(6.6463499693245, -2.0853435542906, 0.0):BLANK=MidBlnk); poi_free(#370,vec(6.4800641638531, 3.2500680271611, 0.0):BLANK=MidBlnk); poi_free(#380,vec(14.517211428303, 3.5734263048248, 0.0):BLANK=MidBlnk); poi_free(#390,vec(19.394928388797, 8.63937265489, 0.0):BLANK=MidBlnk); poi_free(#400,vec(19.046769230769, 13.755992575789, 0.0):BLANK=MidBlnk); !*********************************************************************** ! ~ Fore Section Control Points !----------------------------------------------------------------------- mode_global(); poi_free(#440,CrvPts(4):BLANK=ForeBlnk); mode_local(#100); poi_free(#450,vec(4.3256459744377, -1.663900339218, 0.0):BLANK=ForeBlnk); poi_free(#460,vec(4.6281664708429, 3.7776837105083, 0.0):BLANK=ForeBlnk); poi_free(#470,vec(10.880256729884, 7.1602900116896, 0.0):BLANK=ForeBlnk); poi_free(#480,vec(14.411809377346, 14.397421675527, 0.0):BLANK=ForeBlnk); poi_free(#490,vec(13.373205869042, 18.08932348043, 0.0):BLANK=ForeBlnk); !*********************************************************************** ! ~ Bow-X Section Control Points !----------------------------------------------------------------------- mode_global(); poi_free(#520,CrvPts(5):BLANK=Bow_XBlnk); mode_local(#110); poi_free(#530,vec(0.90209028019555, -1.2868340493685, 0.0):BLANK=Bow_XBlnk); poi_free(#540,vec(1.1637294437577, 4.9612991218762, 0.0):BLANK=Bow_XBlnk); poi_free(#550,vec(4.0796914127827, 11.409011701468, 0.0):BLANK=Bow_XBlnk); poi_free(#560,vec(6.5036387340516, 16.14869985246, 0.0):BLANK=Bow_XBlnk); poi_free(#570,vec(5.4098512324584, 21.447560706131, 0.0):BLANK=Bow_XBlnk); !*********************************************************************** ! ~ Bow Stem Curve Control Points - Adjust manually if required !----------------------------------------------------------------------- mode_local(#120); poi_free(#620,vec(3.5, L/180-2.5+0.0004*L, 0.0):BLANK=1); poi_free(#630,vec(5.2, -1.1, 0.0):BLANK=1); poi_free(#640,vec(7.3, 5.7, 0.0):BLANK=1); poi_free(#650,vec(9.4, 12.3, 0.0):BLANK=1); poi_free(#660,vec(9.88, 18.7, 0.0):BLANK=1); poi_free(#670,vec(9.60, 23.1, 0.0):BLANK=1); !*********************************************************************** ! ~ Translate all points into GLOBAL coordinate system !----------------------------------------------------------------------- mode_global(); !*********************************************************************** ! ~ Transfer all Edited Points into the 'Pt' Array !----------------------------------------------------------------------- Pt(Coord,0):=(on(#10)); Pt(Coord,1):=(on(#20)); Pt(Coord,2):=(on(#30)); Pt(Coord,3):=(on(#40)); Pt(Coord,4):=(on(#50)); Pt(Coord,5):=(on(#55)); Pt(Coord,6):=vec(0,0,0); !unused Pt(Stern,0):=(on(#150)); Pt(Stern,1):=(on(#160)); Pt(Stern,2):=(on(#170)); Pt(Stern,3):=(on(#180)); Pt(Stern,4):=(on(#190)); Pt(Stern,5):=(on(#200)); Pt(Stern,6):=vec(0,0,0); !unused Pt(Aft,0):=(on(#280)); Pt(Aft,1):=(on(#290)); Pt(Aft,2):=(on(#300)); Pt(Aft,3):=(on(#310)); Pt(Aft,4):=(on(#320)); Pt(Aft,5):=(on(#330)); Pt(Aft,6):=vec(0,0,0); !unused Pt(Mid,0):=(on(#350)); Pt(Mid,1):=(on(#360)); Pt(Mid,2):=(on(#370)); Pt(Mid,3):=(on(#380)); Pt(Mid,4):=(on(#390)); Pt(Mid,5):=(on(#400)); Pt(Mid,6):=vec(0,0,0); !unused Pt(Fore,0):=(on(#440)); Pt(Fore,1):=(on(#450)); Pt(Fore,2):=(on(#460)); Pt(Fore,3):=(on(#470)); Pt(Fore,4):=(on(#480)); Pt(Fore,5):=(on(#490)); Pt(Fore,6):=vec(0,0,0); !unused Pt(Bow_X,0):=(on(#520)); Pt(Bow_X,1):=(on(#530)); Pt(Bow_X,2):=(on(#540)); Pt(Bow_X,3):=(on(#550)); Pt(Bow_X,4):=(on(#560)); Pt(Bow_X,5):=(on(#570)); Pt(Bow_X,6):=vec(0,0,0); !unused Pt(Bow_CRV,0):=(on(#620)); Pt(Bow_CRV,1):=(on(#630)); Pt(Bow_CRV,2):=(on(#640)); Pt(Bow_CRV,3):=(on(#650)); Pt(Bow_CRV,4):=(on(#660)); Pt(Bow_CRV,5):=(on(#670)); Pt(Bow_CRV,6):=vec(0,0,0); !unused !*********************************************************************** ! ~ Call the main array to create the final 3D boat model !----------------------------------------------------------------------- part(#700,Main(Pt,L)); ENDMODULE