Difference between revisions of "APC Houses Javascript code snippet"
(Created page with "<SCRIPT LANGUAGE="JavaScript"> <!-- hide this script tag's contents from old browsers function compute(form) { PH=(form.nPh.value=="")? "0" : eval(form.nPh.value); ECL=(...") |
|||
Line 1: | Line 1: | ||
+ | <nowiki> | ||
<SCRIPT LANGUAGE="JavaScript"> | <SCRIPT LANGUAGE="JavaScript"> | ||
<!-- hide this script tag's contents from old browsers | <!-- hide this script tag's contents from old browsers | ||
Line 136: | Line 137: | ||
</PRE> | </PRE> | ||
</FONT> | </FONT> | ||
+ | </nowiki> |
Revision as of 00:07, 9 April 2016
<SCRIPT LANGUAGE="JavaScript"> <!-- hide this script tag's contents from old browsers function compute(form) { PH=(form.nPh.value=="")? "0" : eval(form.nPh.value); ECL=(form.ne.value=="")? "0": eval(form.ne.value); AZ=(form.naz.value=="") ? "0" :eval(form.naz.value); with (Math) { form.cusp1.value = sector(1, rad(PH), rad(ECL), rad(AZ)); form.cusp2.value = sector(2, rad(PH), rad(ECL), rad(AZ)); form.cusp3.value = sector(3, rad(PH), rad(ECL), rad(AZ)); form.cusp4.value = sector(4, rad(PH), rad(ECL), rad(AZ)); form.cusp5.value = sector(5, rad(PH), rad(ECL), rad(AZ)); form.cusp6.value = sector(6, rad(PH), rad(ECL), rad(AZ)); form.cusp7.value = sector(7, rad(PH), rad(ECL), rad(AZ)); form.cusp8.value = sector(8, rad(PH), rad(ECL), rad(AZ)); form.cusp9.value = sector(9, rad(PH), rad(ECL), rad(AZ)); form.cusp10.value = sector(10, rad(PH), rad(ECL), rad(AZ)); form.cusp11.value = sector(11, rad(PH), rad(ECL), rad(AZ)); form.cusp12.value = sector(12, rad(PH), rad(ECL), rad(AZ)); } } function exampledata(form) { document.form.nPh.value = "48.416667"; document.form.ne.value = "23.456389"; document.form.naz.value = "344.166667"; document.form.cusp1.value = ""; document.form.cusp2.value = ""; document.form.cusp3.value = ""; document.form.cusp4.value = ""; document.form.cusp5.value = ""; document.form.cusp6.value = ""; document.form.cusp7.value = ""; document.form.cusp8.value = ""; document.form.cusp9.value = ""; document.form.cusp10.value = ""; document.form.cusp11.value = ""; document.form.cusp12.value = ""; } function resetform(form) { document.form.nPh.value = ""; document.form.ne.value = "23.45"; document.form.naz.value = ""; document.form.cusp1.value = ""; document.form.cusp2.value = ""; document.form.cusp3.value = ""; document.form.cusp4.value = ""; document.form.cusp5.value = ""; document.form.cusp6.value = ""; document.form.cusp7.value = ""; document.form.cusp8.value = ""; document.form.cusp9.value = ""; document.form.cusp10.value = ""; document.form.cusp11.value = ""; document.form.cusp12.value = ""; } /* Utility functions and global variables */ var pi=Math.PI; function rad(gr) { return pi * gr / 180; } function gra(ra) { if (ra<0) ra=ra+2*pi; return Fmod((180 * ra / pi), 360); } function Sgn(x) { return Math.floor(x/Math.abs(x)+.5) } function Fmod(x,y) {return x-y*Math.floor(x/y) } function Sin(x) { return Math.sin(x) } function Cos(x) { return Math.cos(x) } function Tan(x) { return Math.sin(x)/Math.cos(x) } function ATan(x) { return Math.atan(x) } function ATan2(x, y) { return Math.atan(Math.abs(x)/y)*Sgn(x)+pi*(y<0)} function ASin(x) { return Math.asin(x) } function ACos(x) { return Math.acos(x) } <!-- A.P.C. houses (input ph, e, az in radians, output in degrees)--> function sector(n, ph, ecl, az) { var dasc, kv, a; kv = ATan(Tan(ph) * Tan(ecl) * Cos(az)/(1 + Tan(ph) * Tan(ecl) * Sin(az))); dasc = ATan(Sin(kv) / Tan(ph)); if (n<8) {a = kv + az + pi/2 + (n - 1) * (pi/2 - kv) / 3;} else {a = kv + az + pi/2 + (n - 13) * (pi/2 + kv) / 3;} return gra(ATan2(Tan(dasc) * Tan(ph) * Sin(az) + Sin(a), Cos(ecl) * (Tan(dasc) * Tan(ph) * Cos(az) + Cos(a)) + Sin(ecl) * Tan(ph) * Sin(az - a))); } // done hiding from old browsers --> </SCRIPT> </HEAD> <BODY onLoad="exampledata(); compute(document.form);"> <TABLE class="overlay" width="100%"> <TR><TD> <BR> <FORM NAME="form"> <UL> <H3> Enter the appropriate values here </H3> </UL> <FONT size="+1"> <PRE> G.Lat <INPUT TYPE="text" NAME="nPh" SIZE=20> <INPUT TYPE="button" VALUE=" Reset form " OnClick="resetform(this.form)"> E <INPUT TYPE="text" NAME="ne" SIZE=20> <INPUT TYPE="button" VALUE=" Example data " OnClick="exampledata(this.form); compute(this.form);"> ARMC <INPUT TYPE="text" NAME="naz" SIZE=20> <INPUT TYPE="button" VALUE=" Calculate " OnClick="compute(this.form)"> </PRE> </FONT> <UL> <H3> APC Cusps </H3> </UL> <FONT size="+1"> <PRE> 1 <INPUT TYPE="text" NAME="cusp1" SIZE=20> 7 <INPUT TYPE="text" NAME="cusp7" SIZE=20> 2 <INPUT TYPE="text" NAME="cusp2" SIZE=20> 8 <INPUT TYPE="text" NAME="cusp8" SIZE=20> 3 <INPUT TYPE="text" NAME="cusp3" SIZE=20> 9 <INPUT TYPE="text" NAME="cusp9" SIZE=20> 4 <INPUT TYPE="text" NAME="cusp4" SIZE=20> 10 <INPUT TYPE="text" NAME="cusp10" SIZE=20> 5 <INPUT TYPE="text" NAME="cusp5" SIZE=20> 11 <INPUT TYPE="text" NAME="cusp11" SIZE=20> 6 <INPUT TYPE="text" NAME="cusp6" SIZE=20> 12 <INPUT TYPE="text" NAME="cusp12" SIZE=20> </PRE> </FONT>