Post Reply 
Azimuth/Bearing Conversions (using trig functions)
05-16-2019, 12:19 PM
Post: #1
Azimuth/Bearing Conversions (using trig functions)
Blog: http://edspi31415.blogspot.com/2019/05/c...prime.html

The programs A2B (Azimuth to Bearing) and B2A (Bearing to Azimuth) convert angles between two measuring systems that are commonly used by civil engineers and navigators.

The program uses an unusual approach: the use of the arcsine, sine, and cosine functions. These functions are used on because on scientific calculators, the trigonometric functions return answers in specific ranges.

Let x be a real number. then:

asin(x) returns answers in the range -90° to 90° (-π/2 to π/2 radians)

acos(x) returns answers in the range 0° to 180° (0 to π radians)

atan(x) returns answers in the range -90° to 90° (-π/2 to π/2 radians)

This was used in the HP 33E program from the calculator book "HP 33E: Surveying Applications". See Source below.

Formulas:

A = azimuth
B = bearing
Q = quadrant (1,2,3,4)

Azimuth to Bearing:

B = abs( asin( sin A ) )
Q = int(A/90 + 1)

(Yes, the asin/sin is there for a purpose: to get an angle in the range of -90° to 90°)

Bearing to Azimuth: [formula here]

A = 180° * int(Q/2) - B * cos(Q * 180°)

In the programs A2B and B2A, both input and output will be degrees-minutes-seconds format.

HP Prime Program A2B (Azimuth to Bearing)

EXPORT A2B(A)
Code:
BEGIN
// Azimuth to Bearing
HAngle:=1;  // Degrees
LOCAL B, Q, L0:={"NE","SE","SW","NW"};
B:=ABS(ASIN(SIN(A)));
Q:=IP(A/90+1);
RETURN { →HMS(B), L0(Q) }
END;

Example 1: 220° 15' 36"
Result: 40°15'36". SW

Example 2: 184°00'14"
Result: 4°00'14" SW
HP Prime Program B2A (Bearing to Azimuth)

Arguments: Bearing, Quadrant. You can enter Quadrant by a string or numerical quadrant. "NE" = 1, "SE" = 2, "SW" = 3, "NW" = 4

EXPORT B2A(B,q)
Code:
BEGIN
// Bearing to Azimuth
// q "NE", "SE", "SW", "NW"
// or 1,2,3,4
LOCAL A, L0:={"NE","SE","SW","NW"};
HAngle:=1;  // Degrees
// deal with strings
IF TYPE(q)==2 THEN
q:=POS(L0,q);
END;
A:= 180 * IP(q/2) - B * cos(q * 180);
RETURN →HMS(A);
END;

Example 3: 43°21'55" SW (q = 3)
Result: 223°21'55"

Example 4: 13°14'56" SE (q = 2)
Result: 166°45'04"

Source:

Hewlett Packard. "HP33E: Surveying Applications" Hewlett Packard Company. March 1978
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)