11-06-2017, 10:57 PM
The following program will convert Azimuths to a Bearing/Quadrant format and vice versa. The quadrants are numbered from 1 to 4 starting in the north east and working clockwise.
After executing the program BEARING will be displayed. At this point enter the bearing to be converted in H.P. notation(dd.mmsss) followed by R/S. If a bearing was entered then QUADRANT will be displayed, enter the quadrant followed by R/S. The display will now show the azimuth in H.P. notation on the X register. Pressing R/S at this point will display BEARING. If no bearing is entered or, a bearing of 3.14159265359 is entered the program will display AZIMUTH. Enter the azimuth to be converted in H.P. notation and press R/S. The display will now show the bearing in H.P. notation on the Y register and the quadrant on the X register. At this point if R/S is pressed the display will show AZIMUTH. If no azimuth was entered, or an azimuth of 3.14159265359 was entered the program will display BEARING. Pressing R/S and not entering anything in will switch between BEARING and AZIMUTH.
The variables used by this program are:
A, stores the azimuth in decimal degrees.
B, stores the bearing in decimal degrees.
Q, stores the quadrant number 1-4 where 1 is north east, 2 is south east, 3 is south west, and 4 is north west.
To take a bearing and quadrant and convert it to an azimuth:
For the north-east quadrant, the bearing is the azimuth.
For the south-east quadrant, the bearing needs to be subtracted from 180 to obtain the azimuth.
For the south west quadrant, the bearing must be added to 180 to obtain the azimuth.
For the north-west quadrant, the bearing must be subtracted from 360 to obtain the azimuth.
First the quadrant is divided by 2 and the integer portion multiplied by 180. This will produce either a 0, 180, 180, or 360 depending on the quadrant.
Then the cosine of the quadrant multiplied by 180 is taken which will produce either +1 or -1. This is multiplied by the baring which makes it negative for the north-west and south-east quadrants or positive for the north-east and south-west quadrants.
The result is then added to the first step to produce the azimuth.
To convert an azimuth to a bearing and quadrant is a little easier.
First the integer portion of the azimuth is divided by 90 and the integer portion taken.
The result is added to 1 to obtain the quadrant.
Then the arcsine of the sine of the azimuth is taken of which the absolute value is the bearing.
Code:
B001 LBL B
B002 SF 10
B003 π
B004 π
B005 BEARING
B006 X=Y?
B007 GTO B029
B008 HMS→
B009 STO B
B010 QUADRANT
B011 STO Q
B012 RCL Q
B013 2
B014 ÷
B015 IP
B016 180
B017 x
B018 RCL Q
B019 180
B020 x
B021 COS
B022 RCL B
B023 x
B024 -
B025 STO A
B026 →HMS
B027 STOP
B028 GTO B003
B029 π
B030 π
B031 AZIMUTH
B032 X=Y?
B033 GTO B003
B034 HMS→
B035 STO A
B036 IP
B037 90
B038 INT÷
B039 1
B040 +
B041 STO Q
B042 RCL A
B043 SIN
B044 ASIN
B045 ABS
B046 STO B
B047 →HMS
B048 RCL Q
B049 STOP
B050 GTO B029
B051 RTN
After executing the program BEARING will be displayed. At this point enter the bearing to be converted in H.P. notation(dd.mmsss) followed by R/S. If a bearing was entered then QUADRANT will be displayed, enter the quadrant followed by R/S. The display will now show the azimuth in H.P. notation on the X register. Pressing R/S at this point will display BEARING. If no bearing is entered or, a bearing of 3.14159265359 is entered the program will display AZIMUTH. Enter the azimuth to be converted in H.P. notation and press R/S. The display will now show the bearing in H.P. notation on the Y register and the quadrant on the X register. At this point if R/S is pressed the display will show AZIMUTH. If no azimuth was entered, or an azimuth of 3.14159265359 was entered the program will display BEARING. Pressing R/S and not entering anything in will switch between BEARING and AZIMUTH.
The variables used by this program are:
A, stores the azimuth in decimal degrees.
B, stores the bearing in decimal degrees.
Q, stores the quadrant number 1-4 where 1 is north east, 2 is south east, 3 is south west, and 4 is north west.
To take a bearing and quadrant and convert it to an azimuth:
For the north-east quadrant, the bearing is the azimuth.
For the south-east quadrant, the bearing needs to be subtracted from 180 to obtain the azimuth.
For the south west quadrant, the bearing must be added to 180 to obtain the azimuth.
For the north-west quadrant, the bearing must be subtracted from 360 to obtain the azimuth.
First the quadrant is divided by 2 and the integer portion multiplied by 180. This will produce either a 0, 180, 180, or 360 depending on the quadrant.
Then the cosine of the quadrant multiplied by 180 is taken which will produce either +1 or -1. This is multiplied by the baring which makes it negative for the north-west and south-east quadrants or positive for the north-east and south-west quadrants.
The result is then added to the first step to produce the azimuth.
To convert an azimuth to a bearing and quadrant is a little easier.
First the integer portion of the azimuth is divided by 90 and the integer portion taken.
The result is added to 1 to obtain the quadrant.
Then the arcsine of the sine of the azimuth is taken of which the absolute value is the bearing.