!********************************************** BASIC GEOMETRY MODULE calmsect( REF hull_id >"@t16 Select hull surface !"; FLOAT ywl >"Enter y-position of CWL!"); !* Calculation of section with max beam and !* area of this section. !* !* Calculates and stores: !* !* BEAM(3) = max. beam !* SECTAREA(2) = area of section with max beam !* !* (C)Microform AB, J.Kjellander !* Stephan Helma !* !********************************************** INT i,font,ns_geo,ns_gra,status; FLOAT mb_beam,mb_area, dl, k(3); VECTOR pa,pb; REF wp_id; STRING s*132; BEGINMODULE !* !***Global ID of hull surface. !* hull_id:=global_ref(hull_id,9); !* !***Global ID of waterplane. !* set_root_gm(); wp_id:=get_next_gm(1,16384,"waterpl"); if wp_id = #0.1 then exit("No waterplane found !"); endif; !* !***Get y-value of waterplane. !* ywl:=getflt(wp_id,2); !* !***ID for waterplane b_plane. !* s:=rstr(wp_id); wp_id:=rval(s+"#1"); !* !***Create actual waterplane curve by intersecting !***hullsurface with waterplane surface b_plane. !* cur_int(#1,hull_id,wp_id:BLANK=0,PEN=5); !* !***To calculate prismatic coefficient we need the max !***beam of the waterline so we can calculate the area !***of the max beam section. NOTE, this is not neccesary !***the same station as MAXBEAM of the entire hull ! !* psh_pmt("Calculating location of max beam !"); getcurh(#1,font,dl,ns_geo,ns_gra); pb:=vec(0,0,0); for i:=0 to 25*ns_geo do pa:=on(#1,i/25); if pa.z > pb.z then pb:=pa; endif; endfor; part(#5,sectarea(hull_id,wp_id,ywl,pb.x,mb_beam,mb_area)); k(1):=pb.x; k(2):=ywl; k(3):=mb_beam; status:=deldat_gm("BEAM"); status:=putdat_gm("BEAM",3,k); k(1):=mb_area; k(2):=pb.x; status:=deldat_gm("SECTAREA"); status:=putdat_gm("SECTAREA",2,k); pop_pmt(); ENDMODULE !*****************************************************