Sunday, May 4, 2014

PCalc: Programming Examples

For introduction to programming the PCalc iOS app, please click on this link:

http://edspi31415.blogspot.com/2014/05/pcalc-programming-introduction.html

PCalc:

Degrees Minutes Seconds to Decimal Degrees (DMS > D)

Converts DD.MMSSsssss to DD.dddddddddddd
D: Degrees
M: Minutes
S: Seconds

Example:
Input: 45.1535 (45° 15' 35")
Output: 45.2597222222 (≈ 45.25972°)

Program:
Decimal Mode
Set R0 To X
Truncate X
Set R1 To R0
Subtract X From R1
Multiply R1 By 100
Set R2 To R1
Truncate R1
Subtract R1 From R2
Divide R2 By 60
Multiply R2 By 100
Add R1 To R2
Divide R2 By 60
Add R2 To X


Decimal Degrees to Degrees Minutes Seconds (D > DMS)

Converts DD.ddddddd to DD.MMSSsssss where
D: Degrees
M: Minutes
S: Seconds

Example:
Input: 6.375 (6.375°)
Output: 6.2230 (6°22'30")

Decimal Mode
Set R0 To X
Truncate X
Set R1 To R0
Subtract X From R1
Multiply R1 By 60
Set R2 To R1
Truncate R1
Multiply R1 By 0.01
Add R1 To X
Set R3 To R2
Truncate R3
Subtract R3 From R2
Multiply R2 By 0.006
Add R2 To X


Stopping Sight Distance (in feet)

Input:
Y: design vehicle speed (miles per hour)
X: grade (in percentage)

Output:
X: Stopping sight distance in feet

Standard constants are used: deceleration of the car is assumed to be 11.2 ft/s^2.

Example:
Input:
Y: 45 mph
X: 2 (2% grade)

Output:
X: 249.8576858108 (feet)

Decimal Mode
Set R0 To 22/15
Multiply R0 By Y
Multiply X By 0.32
Add 11.2 To X
Invert X
Multiply X By 1.075
Y To Power of 2
Multiply X By Y
Add R0 To X


Perfect Trajectory (Projectile Motion without Air Resistance starting from point (0,0))

Input:
Y: Velocity in meters/second
X: Angle in Degrees

Output:
Y: Maximum Height in meters
X: Range of Projectile in meters

Example:
Input: Y: 30, X: 30
Output (to 4 decimal places): Y: 11.4718, X: 79.4790

Program:
Decimal Mode
Degrees Mode
Set R1 To 19.6133
Invert R1
Set R0 To X
Sine R0
R0 To The Power of 2
Multiply R1 By R0
Set R0 To Y
R0 To The Power of 2
Multiply R1 By R0
Set R2 To 9.80665
Invert R2
Set R0 To X
Multiply R0 By 2
Sine R0
Multiply R2 By R0
Set R0 To Y
R0 To The Power of 2
Multiply R2 By R0
Set X To R2
Set Y To R1


Eddie


This blog is property of Edward Shore. 2014

Spotlight: Akron Brass FireCalc Pocket Computer

Spotlight: Akron Brass FireCalc Pocket Computer Welcome to a special Monday Edition of Eddie’s Math and Calculator blog. Thi...