Showing posts with label civil engineering. Show all posts
Showing posts with label civil engineering. Show all posts

Sunday, May 3, 2026

HP 65 Programs: Triangulation, Percentile, Roots of Unity, Partial Fractions

 HP 65 Programs: Triangulation, Percentile, Roots of Unity, Partial Fractions


Triangulation

(done with HP-65 Emulator for Windows, Bernhard Emese)




Given:

Side angle α

Side angle ß

r = Length of base

Find:

h = height which crosses the base line at right angles



Code:

23: LBL

12: B

35: g

41: DEG

33 01: STO 1

35 08: R↓

41: ENTER

41: ENTER

44: CLX

51: -

31: f

04: SIN

35 09: R↑

31: f

04: SIN

71: *

33: STO

71: *

01: 1

35 08: R↓

61: +

31: f

04: SIN

33: STO

81: ÷

01: 1

34 01: RCL 1

24: RTN



Example: ß = 50°, α = 30°, r = 10

Result: h ≈ 3.89


Source:

“Triangulation (surveying)” Wikipedia. https://en.wikipedia.org/wiki/Triangulation (surveying) (last edited October 24, 2025). Retried March 17, 2026


Percentile in a Range


The program calculates the percentile of x in the range [a, b].


percentile = (x – a) ÷ (b – a) * 100%


Stack:

Z: x

Y: a

X: b


23: LBL

11: B

35 07: x<>y

51: -

35 00: LSTx

35 07: R↓

51: -

35 09: R↑

81: ÷

02: 2

32: f^-1

08: LOG (10^x)

71: ×

24: RTN


Example: The range: [210, 470], x = 376

Stack: Z: 376, Y: 210, X: 470

Result: 63.85



Roots of Unity

(done with HP-65 Emulator for Windows, Bernhard Emese)


w^n = 1

Registers used: R1 = n, R8 = n (counter)


n [ A ]


Cycle:

root # [ R/S ]

real part [ R/S ]

imaginary part [ R/S ] (the cycle starts again)


Repeat the cycle until the display is flashing zeros (forced 1/0 error). Hit [ CLx ] to stop the flashing.


This program switches the mode to radians angle measurement.



Code:

23: LBL

11: A

33 01: STO 1

33 08: STO 8

35: g

42: RAD

23: LBL

00: 0 (LBL 0 - subroutine)

34 08: RCL 8

84: R/S (show root #)

35: g

02: π

71: ×

02: 2

71: ×

34 01: RCL 1

81: ÷

01: 1

32: f^-1

01: R->P (->rect)

84: R/S (show real part)

35 07: x<>y

84: R/S (show imaginary part)

35: g

83: DSZ (decrement R8 by 1)

22: GTO

00: 0 (GOTO LBL 0)

34 08: RCL 8

35: g

04: 1/x

24: RTN


Example (FIX 4):

w^3 = 1

#; R/S; real part; R/S; imaginary part

3; 1.0000; -0.0000

2; -0.5000; -0.8660

1; -0.5000; 0.8660

(flashing zeroes)




Partial Fractions

(w is the variable, and T, Z, Y, and X are the stack contents)

(Tw+Z) ÷ ((w+Y)(w+X)) → B÷(w+Y) + A÷(w+X)

Input Stack: T, Z, Y, X 

Output Stack: B, A


Code: 

23: LBL 

11: A 

35, 07: x<>y 

51: - 

35, 00: LST x 

35, 09: R↑ 

71: × 

35, 00: LST x 

35, 07: x<>y 

35, 09: R↑ 

35, 07: x<>y 

51: - 

35, 09: R↑ 

81: ÷ 

41: ENTER 

35, 08: R↓ 

51: - 

35, 09: R↑ 

35, 07: x<>y 

24: RTN



Example 1: 

(12*w + 28) ÷ ((w+2) * (w+3)) = 4 ÷ (w+2) + 8 ÷ (w+3) 

Input Stack: T: 12, Z: 28, Y: 2, X: 3 press [ A ] 

Output Stack: Y (B): 4, X (A): 8



Example 2: 

(33) ÷ ((w-5) * (w+6)) = 3 ÷ (w-5) + -3 ÷ (w+6) 

Input Stack: T: 0, Z: 33, Y: -5, X: 6 press [ A ] 

Output Stack: Y (B): 3, X (A): -3



Example 3: 

(2*w - 3) ÷ ((w-1) * (w+4)) = -0.2 ÷ (w-1) + 0.2 ÷ (w+4) 

Input Stack: T: 2, Z: -3, Y: -1, X: 4 press [ A ] 

Output Stack: Y (B): -0.2, X (A): 0.2





Eddie


All original content copyright, © 2011-2026. Edward Shore. Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited. This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.

Saturday, July 20, 2024

Swiss Micros DM41X and Casio fx-CG 50: Minor Head Loss

Swiss Micros DM41X and Casio fx-CG 50: Minor Head Loss



Introduction


When a fluid, such as water, is flowing in a pipe system, energy is lost from the flow due to friction. This loss is known as head loss. The equation presented here is an equation to determine head loss occurring in pipe bends and joints (entrances and exits), which is categorized as minor loss. Minor losses are typically summarized with major losses to determine total head loss.


A formula for minor head loss is stated as:


h = C * v^2 / (2 * g)


where:

h = head loss (m)

C = coefficient

v = velocity of the fluid (m/s)

g = Earth’s gravity = 9.80665 m/s^2 (2 * g = 19.6133 m/s^2)

C = head loss coefficient (see table below)


Type # for C

Value

1. Sharp Exit

1

2. Protruding Entrance

0.8

3. Sharp Entrance

0.5

4. Round Entrance

0.1


If we fit the above table like so:


Type # for C

Value

1

1

2

0.8

3

0.5

4

0.1


Fortunately, the data above (and only the data above) can fit into the quadratic equation:

y = -0.05 * x^2 – 0.05 * x + 1.1 = -0.05 * (x^2 + x) + 1.1


where x is the type number and y is the corresponding coefficient. The assignment of type numbers is arbitrarily.


In the code for the DM41X, I use the polynomial to grab the required coefficient of the user’s choice, mapping choice 1 to C =1 for sharp exit, mapping choice 2 to C = 0.8 for protruding entrance, and so on. I got really lucky because the quadratic equation presented a perfect fit (r^2 = 1). In programming it can serve as alternative way to retrieve coefficient values (but the fit has to be perfect or near perfect with minor adjustments).



Swiss Micros DM41X Code: HEADLOS

(HP 41C compatible, no modules needed)


01 LBL^T HEADLOS

02 LBL 00

03 ^T SHARP EXIT

04 AVIEW

05 PSE

06 PSE

07 ^T PROTRUDING

08 AVIEW

09 PSE

10 PSE

11 ^T 3 SHARP ENT.

12 AVIEW

13 PSE

14 PSE

15 ^T 4 ROUND ENT.

16 AVIEW

17 PSE

18 PSE

19 ^T TYPE?

20 PROMPT

21 INT

22 STO 00 (comparison: reject if the entry is negative or greater than 5)

23 X<=0?

24 GTO 00

25 5

26 X<=Y?

27 GTO 00

28 RCL 00

29 X↑2

30 RCL 00

31 +

32 -20

33 /

34 1.1

35 +

36 ^T VEL. <M/S>?

37 PROMPT

38 X↑2

39 *

40 19.6133

41 /

42 ^T HEAD LOSS=

43 ARCL X

44 RTN

45 END


Casio fx-CG 50 Program HEADLOSS


Menu “TYPE”, “SHARP EXIT”, 1, “PROTRUDING”, 2, “SHARP ENTRANCE”, 3, “ROUND ENTRANCE”, 4

Lbl 1: 1 → C: Goto 5

Lbl 2: 0.8 → C: Goto 5

Lbl 3: 0.5 → C: Goto 5

Lbl 4: 0.1 → C: Goto 5

Lbl 5

“VELOCITY (M _| S)”? → V ( _| is the fraction character [ []/[] ] )

C × V² ÷ 19.6133 → H

“HEAD LOSS:”

H


Example


For the velocity, v = 10.5 ft/s ≈ 3.2004 m/s:


Type

Head Loss (h)

1. Sharp Exit

0.5222

2. Protruding Entrance

0.4178

3. Sharp Entrance

0.2611

4. Round Entrance

0.0522



Sources


Ajmera, Benna. “Engineering Formulas” Quick Study Academic. BarCharts, Inc. 2014


“Minor Losses in Pipes and Ducts“ Ansys. 2020. https://courses.ansys.com/wp-content/uploads/2020/09/Lesson-4-Minor-Losses-in-Pipes-and-Ducts-Handout.pdf Retrieved June 6, 2024.



Until next time,


Eddie


All original content copyright, © 2011-2024. Edward Shore. Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited. This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.

Saturday, June 8, 2024

Casio fx-4000P - The Programs I took on Vacation

 Casio fx-4000P - The Programs I took on Vacation


I was on vacation in Atascadero last May 2024 at a car conference with my partner. I may not have classic cars, but I do have classic calculators. Here the programs I took with me in Casio fx-4000P.
I also took my HP 45 with me as well.


Total: 448 bytes out of 550 bytes ( ^ => x^y)


Prog 0: Quadratic Equation: Po Shen way: x^2 + B * x + C = 0, built for real roots (39 steps)


“ B “ : ? → B : “C” : ? → C : B² ÷ 4 – C → W ◢ -B ÷ 2 - √W ◢ Ans + 2 × √W


Prog 1: Law of Cosines - Side Z (45 steps)


Deg : “X” : ? → X : “Y” : ? → Y : “C” : ? → C : X² + Y² – 2 × X × Y × cos C : √Ans → Z


Prog 2: Law of Cosines - Angle C (49 steps)


Deg : “X” : ? → X : “Y” : ? → Y : “Z” : ? → Z : ( X² + Y² – Z² ) ÷ ( 2 × X × Y ) : cos^-1 Ans → C


Prog 3: Area of Triangle – Heron’s Formula (55 steps)


X” : ?→X : “Y” : ?→Y : “Z” : ?→Z : (X + Y + Z) ÷ 2→S : √( S×(S – X)×(S – Y)×(S – Z))


Prog 4: Speed of Sound in Dry Air (53 steps)

All constants, γ, R, M are taken care of in the formula, T = temp in °F

Conversions: 1 m/s = 2.236936 mph, 20.04503702 * 2.236936 = 44.83946493


T “ : ?→T : 5÷9 × (T – 32) + 273.15 : 20.04503702 * √Ans : 2.236936 * Ans → S


Prog 5: Horizontal Curve Analysis Given Central Angle and Radius (52 steps)

I = central angle, R = radius, L = arc length, C = chord length


Deg : “I” : ?→I : “R” : ?→R : “L=” ◢ π×R×I ÷ 180 → L ◢ “C=” ◢ 2×R× sin(I ÷ 2) → C


Prog 6: D = Displacement of a Cylinder (in) (36 steps)

B = bore (in), S = stroke (in), N = number of cylinders


“B” : ? → B : “S” : ? → S : “N” : ? → N : π × B² × S × N ÷ 4 → D


Prog 7: Tire Size (in) (36 steps)

S = section width (mm), A = aspect ratio, R = rim diameter (S, A, R → )


“S” : ? → S : “A” : ? → A : “R” : ? → R : S × A ÷ 1270 + R → T


Prog 8: Air Pressure for height up to 36,089 ft above sea level (inHg) (45 steps)

This is with constants already completed (g, M, R, etc.)


H” : ?→H : 29.92126 × (1 - 6.875 × 10^-6 × H) x^y 5.255876329 → P


Prog 9: Breaking Distance in Feet Given the Car’s Velocity in Miles Per Hour (35 steps)


V” : ? → V : V × 22 ÷ 15 : Ans × 1.5 + Ans² ÷ 45.04367 → D


Source:

“Breaking Distance” Wikipedia. Last Edited March 30, 2024. Accessed April 29, 2024.

https://en.wikipedia.org/wiki/Braking_distance


Hagberg Media AB. “Stopping distance = reca2tion distance + breaking distance” 2024.

Accessed April 29, 2024. https://korkortonline.se/en/theory/reaction-braking-stopping/


Just for fun,

Eddie


All original content copyright, © 2011-2024. Edward Shore. Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited. This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.


Thursday, May 5, 2022

HP 32S and HP 32SII Week: Jurin's Law - Capillary Rise

HP 32S and HP 32SII Week:  Jurin's Law - Capillary Rise 





Capillary Motion 


Jurin's law describes the motion of liquid in small tubes, as the height is inversely proportional to the tube's diameter (and radius).  Factors include the contact angle and the density of the liquid.


The height of the liquid is determined by:


h = (2 * σ * cos θ) / (ρ * g * r)


σ = surface tension of the liquid (N/m)  (T)

θ = the angle of liquid in degrees, from adhesive (0° to 90°) to cohesive (90° to 180°) (B)

ρ = density of liquid (kg/m^3) (D)

r = radius of the tube (m) (R)


HP 32S and HP 32SII: Jurin's Law

Size:  33.5 bytes


J01 LBL J

J02 DEG

J03 INPUT T

J04 INPUT B

J05 INPUT D

J06 INPUT R

J07 2

J08 RCL× T

J09 RCL B

J10 COS

J11 ×

J12 RCL D

J13 RCL× R

J14 9.80665

J15 ×

J16 ÷

J17 STOP


Example:

Find the capillary rise of water in a tube with radius of 0.1 m.   

Data:  σ = 0.0728 N/m, θ = 0°, and ρ = 1000 kg/m^3


Inputs:

T = 0.0728

B = 0

D = 1000

R = 0.1


Result:  1.48470681E-4 m  (height)


Source:


"Jurin's law" Wikipedia.  Last updated February 11, 2022.  https://en.wikipedia.org/wiki/Jurin%27s_law  Last Accessed April 1, 2022.  


Lindeburg, Michael R. PE   Civil Engineering Reference Manual for the PE Exam 14th Edition  Professional Publications, Inc:  Belmont, CA.  pp. 14-11 to 14-13


Eddie


All original content copyright, © 2011-2022.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author. 


Wednesday, May 4, 2022

HP 32S and HP 32SII Week: Total Drag

HP 32S and HP 32SII Week:  Total Drag





Introduction


The following equation calculates the total drag force applied to parallel to an area in the opposite direction of the object's motion.  


Fd = 1/2 * ρ * v^2 * Cd * A,   ρ = P / (R * T)


ρ = air pressure 

P = absolute pressure (101,325 Pa, 14.696 psi, 2116.224 lb/ft^2)

R = specific gas constant (287.03 J/(kg k), 53.3533 (ft lbf/lb °R))

T = temperature (K = °C + 273.15, °R = °F + 459.67)


A = cross area that the drag force is applied (m^2, ft^2)

V = velocity of the object (m/s, ft/s)

Cd = drag coefficient (unitless)


The program gives outputs:


ρ = air pressure (kg/m^3, lb/ft^3)

Fd = total drag (kg*m/s^2, lb*ft/s^2)


HP 32S/32SII Program:  Total Drag, SI Units

Size: 55.5 bytes


F01 LBL F

F02 INPUT C

F03 INPUT A

F04 INPUT V

F05 INPUT T

F06 273.15

F07 +

F08 287.03

F09 ×

F10 1/x

F11 101,325

F12 ×

F13 STOP

F14 RCL× C

F15 RCL× A

F16 RCL V

F17 x^2

F18 ×

F19 2

F20 ÷

F21 STOP


Example:

C = drag coefficient = 0.31

A = area =7.0686 m^2

T = temperature = 18.8 °C

V = velocity = 3 m/s


Results:

ρ = 1.20915184207 kg/m^3

Fd = 11.9230799416 kg*m/s^2


HP 32S/32SII Program:  Total Drag, US Units

Size: 55.5 bytes


F01 LBL F

F02 INPUT C

F03 INPUT A

F04 INPUT V

F05 INPUT T

F06 459.67

F07 +

F08 53.3533

F09 ×

F10 1/x

F11 2116.224

F12 ×

F13 STOP

F14 RCL× C

F15 RCL× A

F16 RCL V

F17 x^2

F18 ×

F19 2

F20 ÷

F21 STOP


Example:

C = drag coefficient = 0.31

A = area =76.0868 ft^2

T = temperature = 65.84 °F

V = velocity = 9.84252 ft/s


Results:

ρ = 7.54778228E-2 lb/ft^3

Fd = 86.232900381 lb*ft/s^2



Source:


Lindeburg, Michael R. PE   Civil Engineering Reference Manual for the PE Exam 14th Edition  Professional Publications, Inc:  Belmont, CA.  pp. 17-41 and 17-42


All original content copyright, © 2011-2022.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author. 


Saturday, September 14, 2019

TI-84 Plus CE and Casio fx-5800P: Highway Transition Spiral

TI-84 Plus CE and Casio fx-5800P:  Highway Transition Spiral

Introduction



For any given parameters of a highway transition spiral:

PI:  point of intersection of the vertices (X coordinate, Y coordinate; Program Variables A, B)
∆:  intersection angle  (Program variable I)
D_C:  degree of the curve (Program variable D)
L_S:  length of the spiral (Program variable L)

Outputs:

Z:  Angle between the radii of spiral at TS and SC
R:  radius of circular curve
TS:  point of intersection of main tangent and approach spiral   (Program Variables U, V)
SC:  point of intersection of main tangent and circular curve
ST:  short tangent

Formulas:

Z = L * D / 200

Z is in degrees
Convert Z to radians:  Q = Z * π /180

x = L * (1 - Q^2/10)
y = L * (Q/3 - Q^3/43)
k = x - R * sin Z
p = y - R * (1 - cos Z)
T = (R + P) tan (∆/2) + K
S = Y * csc Z = Y / sin Z

Coordinates of TS:
[ PI_X - intg(T/100),  PI_Y - 100 * frac(T/100)]

Coordinates of SC:
[ TS_X + intg(L/100), TS_Y + 100 * frac(L/100)]


TI-84 Plus CE Program HYSPIRAL
(program to be typed)

Degree
"EWS 2019-08-03"
Disp "HWY SPIRAL"
Input "PI X: ",A
Input "+ PI Y: ",B
Input "INT-ANGLE: ",I
Input "LENGTH: ",L
Input "DEGREE: ",D
L*D/200→Z
100/(D*π/180)→R
Zπ/180→Q
L(1-Q²/10)→X
L(Q/3-Q³/43)→Y
X-R sin(Z)→K
Y-R (1-cos(Z))→P
(R+P) tan(I/2)+K→T
Y/sin(Z)→S
Disp "ANGLE TS-SC:",Z,"RADIUS:",R
Pause
A-iPart(0.01T)→U
B-100 fPart(0.01T)→V
Disp "TS:",U,"+",V
Pause
Disp "SC:",U+iPart(0.01L),"+",V+100 fPart(0.01L)
Pause
Disp "ST:",S

Casio fx-5800P Program HWYSPIRAL

Deg
"HIGHWAY SPIRAL"
"PI X: "?→A
"PI Y: "?→B
"INT-ANGLE: "?→I
"LENGTH: "?→L
"DEGREE: "?→D
L*D÷200→Z
100÷(D*π÷180)→R
Z*π÷180→Q
L*(1-Q²÷10)→X
L*(Q÷3-Q^(3)÷43)→Y
X-R sin(Z)→K
Y-R (1-cos(Z))→P
(R+P) tan(I÷2)+K→T
Y÷sin(Z)→S
"ANGLE TS-SC:"
Z⊿
"RADIUS:"
R⊿
A-Int(0.01T)→U
B-100 Frac(0.01T)→V
"TS X:"
U⊿
"TS Y:"
V⊿
"SC X:"
U+Int(0.01L)⊿
"SC Y:"
V+100 Frac(0.01L)⊿
"ST:"
S

Example

A highway with a transition spiral is at station 50 + 64.84, with the intersection angle 50°, and the degree of the curve at 6°.  The length of the curve is said to be 360 ft.

Inputs:

PI X = 50
PI Y = 64.84
INT-ANGLE = 50
LENGTH = 360
DEGREE = 6

Outputs:

ANGLE TS-SC = 10.8
RADIUS = 954.9296586
TS:  (X + Y) = 44 + 37.12990632
SC:  (X + Y) = 47 + 97.12990632
ST = 120.4143341

Source:

Hicks, Tyler P.E.  Handbook of Civil Engineering Calculations McGraw Hill: New York.  2000  ISBN 0-07-028814-3


Eddie

All original content copyright, © 2011-2019.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.

Thursday, May 16, 2019

Casio fx-CG50 and HP Prime: Azimuth/Bearing Conversions

Casio fx-CG50 and HP Prime: Azimuth/Bearing Conversions

Introduction




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:

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.

To enter degrees-minutes-seconds:

Casio fx-CG50:  [ OPTN ] [ F6 ] (more) [ F5 ] (ANGLE)  [ F4 ] (° ' ")

HP Prime:  [ Shift ] [ a b/c ] or [ Shift ] [ 9 ] (select °, ', or '' from the menu)

Azimuth to Bearing Program A2B

Casio fx-CG50 Program A2B (Azimuth to Bearing)

ClrText
Locate 1,4,"AZIMUTH TO BEARING"
Deg
"AZ: "? → A
Abs( sin^-1 ( sin A ) ) → B
"BEARING ="
B ▶ DMS ◢
Intg( A ÷ 90 + 1 ) → Q
"QUADRANT = "
Q = 1 ⇒ "NE"
Q = 2 ⇒ "SE"
Q = 3 ⇒ "SW"
Q = 4 ⇒ "NW"

HP Prime Program A2B (Azimuth to Bearing)

EXPORT A2B(A)
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

Bearing to Azimuth Program B2A

Casio fx-CG50 Program B2A  (Bearing to Azimuth) 

ClrText
Locate 1,4,"BEARING TO AZIMUTH"
Deg
"BEARING: "? → B
Menu "QUADRANT", "NE", 1, "SE", 2, "SW", 3, "NW", 4
Lbl 1: 1 → Q: Goto 5
Lbl 2: 2 → Q: Goto 5
Lbl 3: 3 → Q: Goto 5
Lbl 4: 4 → Q: Goto 5
Lbl 5
180 * Intg( Q ÷ 2 ) - B * cos( Q * 180 ) → A
"AZ ="
A ▶ DMS

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)
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

Eddie

All original content copyright, © 2011-2019.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.

Python – Earth’s Radius and Gravity in US Units

Python – Earth’s Radius and Gravity in US Units Introduction The following script, gravus2.py, estimates the Earth’s gravity i...