Horizontal sundial calculations: Difference between revisions

Content added Content deleted
m (→‎{{header|REXX}}: added/changed wording in the REXX section header, added/changed comments and whitespace, optimized the ATAN function.)
m (→‎{{header|REXX}}: calculated the legal meridian instead of using a specified amount.)
Line 2,032: Line 2,032:
The REXX language doesn't have the usual trigonometric functions, nor for that matter, a   '''sqrt'''   (square root) function,
The REXX language doesn't have the usual trigonometric functions, nor for that matter, a   '''sqrt'''   (square root) function,
<br>so these as well as &nbsp; '''pi''' &nbsp; were added to this program.
<br>so these as well as &nbsp; '''pi''' &nbsp; were added to this program.

The &nbsp; ''legal meridian''' &nbsp; is calculated instead of relying on a specified amount.


No attempt was made to explain the inner workings of the trigonometric functions.
No attempt was made to explain the inner workings of the trigonometric functions.
<lang rexx>/*REXX program displays: hour, sun hour angle, dial hour line angle, 6am ───► 6pm. */
<lang rexx>/*REXX program displays: hour, sun hour angle, dial hour line angle, 6am ───► 6pm. */
numeric digits 60 /*in case sundial is in polar regions. */
numeric digits 60 /*in case sundial is in polar regions. */
parse arg lat lng mer . /*obtain optional arguments from the CL*/
parse arg lat lng . /*obtain optional arguments from the CL*/
/* ┌───────────◄ None specified? Then use the default*/
/* ┌───────────◄ None specified? Then use the default*/
/* │ of Jules Verne's Lincoln Island, */
/* │ of Jules Verne's Lincoln Island, */
Line 2,042: Line 2,044:
if lat=='' | lat=="," then lat= -4.95 /*Not specified? Then use the default.*/
if lat=='' | lat=="," then lat= -4.95 /*Not specified? Then use the default.*/
if lng=='' | lng=="," then lng= -150.5 /* " " " " " " */
if lng=='' | lng=="," then lng= -150.5 /* " " " " " " */
if mer=='' | mer=="," then mer= -150 /* " " " " " " */
mer=format(lng/15, , 0) * 15 /*calculate legal meridian longitude. */
sineLat=sin( d2r(lat) ) /*calculate sine of (radian) latitude. */
sineLat=sin( d2r(lat) ) /*calculate sine of (radian) latitude. */
w1=max( length('hour' ), length("midnight" )) + 2 /*compute the max hour width.*/
w1=max( length('hour' ), length("midnight" )) + 2 /*compute the max hour width.*/