HP Prime &
TI-84: Bearing and Azimuth Conversions
Azimuth vs Bearing |
AZ2BE (Azimuth
to Bearing)
Note: Bearings start clockwise from due north. Bearings will be reduced to angles between 0°
to 360°.
Three outputs
will be returned: bearing, direction
string, and quadrant reference number (for reference). The HP Prime version will return a list.
HP Prime AZ2BE:
EXPORT AZ2BE(θ)
BEGIN
// Azimuth to
Bearing
// EWS
2015-07-19
LOCAL q,b,s;
θ≔θ MOD 360;
q≔IP(θ/90)+1;
// Determining
the Bearing Angle
IF q==1 THEN
b≔θ; s:=”NE”;
END;
IF q==2 THEN
b≔ABS(θ-180); s≔”SE”;
END;
IF q==3 THEN
b≔θ-180; s≔”SW”;
END;
IF q==4 THEN
b≔ABS(θ-360); s≔”NW”
END;
RETURN {b,s,q};
END;
TI-84+ AZ2BE:
Input
"ANGLE:",θ
360*fPart(θ/360)+360*(θ<0)→θ
iPart(θ/90)+1→Q
If Q=1:Then
θ→B
"NE"→Str1:End
If Q=2:Then
abs(θ-180)→B
"SE"→Str1
End
If Q=3:Then
θ-180→B
"SW"→Str1
End
If Q=4:Then
abs(θ-360)→B
"NW"→Str1
End
Disp
"BEARING",B
Disp Str1,Q
BE2AZ (Bearing to Azimuth)
Note: Bearings outside of range of 0° to 90° or
quadrant numbers outside of 1 to 4 will result in an “UNEXPECTED RESULT”
message.
Quadrants:
Quadrant 1: Northeast
Quadrant 2: Southeast
Quadrant 3: Southwest
Quadrant 4: Northwest
HP Prime BE2AZ:
EXPORT
BE2AZ(b,q)
BEGIN
// Bearing to
Azimuth
// bearing,
quadrant
// 1 = NE, 2 =
SE, 3 = SW, 4 = NW
// 2015-07-19 EWS
LOCAL θ;
// Are b and q
in the proper range?
IF b<0 OR
b>90 OR q<1 OR q>4 THEN
RETURN “Unexpected
Value”;
KILL;
END;
// Calculation
q≔IP(q);
IF q==1 THEN
θ≔b;
END;
IF q==2 THEN
θ≔180-b;
END;
IF q==3 THEN
θ≔b+180;
END;
IF q==4 THEN
θ≔360-b;
END;
RETURN θ;
END;
TI-84+ BE2AZ:
Input
"BEARING:",B
Disp
"1=NE"
Disp
"2=SE"
Disp
"3=SW"
Disp
"4=NW"
Input
"Q:",Q
If B<0 or
B>90 or Q<1 or Q>4
Then
Disp
"UNEXPECTED VALUE"
Stop
End
iPart(Q)→Q
If Q=1:Then
B→θ:End
If Q=2:Then
180-B→θ:End
If Q=3:Then
B+180→θ:End
If Q=4:Then
360-B→θ:End
Disp
"AZIMUTH:",θ
Examples:
Azimuth: 68°, Bearing: 68° bearing NE (q=1)
Azimuth: 164°,
Bearing: 16° bearing SE (q=2)
Azimuth: 224°,
Bearing: 44° bearing SW (q=3)
Azimuth: 321°,
Bearing: 39° bearing NW (q=4)
This blog is property
of Edward Shore. 2015