|
|
General HydroStatics
Ship Stability Software |
|
Command of the Week
(New or interesting aspects of GHS that you may not know about) |
|
RUN GREATO.WIZ
|
|
|
What do great-circle distances have to do with ship stability?
Nothing as far as we know. But the Part Maker commands that produce this wizard
demonstrate advanced template techniques. Also the trigonometry function ATAN2 is featured.
ATAN2 was added recently to complete Part Maker's offerings of trig functions. This form of the arctangent function takes both x and y arguments instead of y/x. ATAN2(y,x) in Part Maker follows most programming languages: the order of the parameters is y first then x. Some spreadsheets (notably Excel) reverse the order. The GHS main program also provides trig functions in its SET command, which can be used to precalculate things for Part Maker. But as explained in last week's COW, the PMX version of Part Maker is fully capable of performing arithmetic operations independently of the main program. GREATO.WIZ did not exist until now. It is truly a Command of the Week! If you want to include it in your GHS system, copy the code below to a text file, name the file GREATO.WIZ, and move it into your GHS program folder. Then RUN GREATO.WIZ. |
enter pmx /direct real latd1:=48.117, lond1:=-122.76 real latd2:=21.981, lond2:=-159.372 real dnm, dkm, dsm real pi:=3.14159 real rad:= pi/180 real R:=6371 `km macro LL "Point %1:" | "Lat" latd%1 /dec:2 /width:7 | "Long" lond%1 /dec:2 /width:8 / macro Dist d%1 /dec:2 /read /right /width:8 /color:2 /bg:0 | "%2" / template greato "Great Circle Distance" /nokey "Enter latitudes and longitudes in decimal degrees" "(negative for West and South)." expand LL (2,1) 1 break "Calculate" .calc /bg:14 break line "Great circle distance from point 1 to point 2:" expand Dist "km", "Kilometers" expand Dist "nm", "Nautical miles" expand Dist "sm", "Statute miles" exit / macro calc `ref: http://www.movable-type.co.uk/scripts/latlong.html real dlat:=(latd2-latd1)*rad real dlon:=(lond2-lond1)*rad real t:=SIN(dlat/2) real u:=SIN(dlon/2) real a:=t*t+COS(latd1*rad)*COS(latd2*rad)*u*u dkm:=2*R*ATAN2(SQRT(a),SQRT(1-a)) dnm:=dkm/1.852 dsm:=dkm/1.60934 / .greato quit pm quit |
|
Questions, comments, or requests?
Contact Creative Systems, Inc. USA phone: 360-385-6212 Fax: 360-385-6213 Office hours: 7:00 am - 4:00 pm Pacific Time, Monday - Friday Mailing address: PO Box 1910 Port Townsend, WA 98368 USA Click here for an index to this and previous COWs |