How to resolve the algorithm Angle difference between two bearings step by step in the BASIC programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Angle difference between two bearings step by step in the BASIC programming language
Table of Contents
Problem Statement
Finding the angle between two bearings is often confusing.[1]
Find the angle which is the result of the subtraction b2 - b1, where b1 and b2 are the bearings. Input bearings are expressed in the range -180 to +180 degrees. The result is also expressed in the range -180 to +180 degrees.
Compute the angle for the following pairs:
Allow the input bearings to be any (finite) value.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Angle difference between two bearings step by step in the BASIC programming language
Source code in the basic programming language
100 cls
110 sub getdifference(b1,b2)
120 r = (b2-b1) mod 360
130 if r >= 180 then r = r-360
140 print using "#######.######";b1;
150 print using " #######.######";b2;
160 print using " #######.######";r
170 end sub
180 print "Input in -180 to +180 range:"
190 print " b1 b2 difference"
200 print " -------------------------------------------------"
210 getdifference(20,45)
220 getdifference(-45,45)
230 getdifference(-85,90)
240 getdifference(-95,90)
250 getdifference(-45,125)
260 getdifference(-45,145)
270 getdifference(-45,125)
280 getdifference(-45,145)
290 getdifference(29.4803,-88.6381)
300 getdifference(-78.3251,-159.036)
310 getdifference(-70099.742338,29840.674379)
320 getdifference(-165313.66663,33693.989452)
330 getdifference(1174.838051,-154146.664901)
340 print
350 print "Input in wider range:"
360 print " b1 b2 difference"
370 print " -------------------------------------------------"
380 getdifference(-70099.742338,29840.674379)
390 getdifference(-165313.66663,33693.989452)
400 getdifference(1174.838051,-154146.664901)
410 getdifference(60175.773068,42213.071924)
SUB getDifference (b1!, b2!)
r! = (b2 - b1) MOD 360!
IF r >= 180! THEN r = r - 360!
PRINT USING "#######.###### #######.###### #######.######"; b1; b2; r
END SUB
PRINT " Bearing 1 Bearing 2 Difference"
CALL getDifference(20!, 45!)
CALL getDifference(-45!, 45!)
CALL getDifference(-85!, 90!)
CALL getDifference(-95!, 90!)
CALL getDifference(-45!, 125!)
CALL getDifference(-45!, 145!)
CALL getDifference(-45!, 125!)
CALL getDifference(-45!, 145!)
CALL getDifference(29.4803, -88.6381)
CALL getDifference(-78.3251, -159.036)
CALL getDifference(-70099.74233810938#, 29840.67437876723#)
CALL getDifference(-165313.6666297357#, 33693.9894517456#)
CALL getDifference(1174.838051059846#, -154146.6649012476#)
SUB getdifference (b1,b2)
LET r = REMAINDER(b2-b1, 360.0)
IF r >= 180.0 THEN LET r = r-360.0
PRINT USING "#######.###### #######.###### #######.######": b1, b2, r
END SUB
PRINT " Bearing 1 Bearing 2 Difference"
CALL getdifference(20.0, 45.0)
CALL getdifference(-45.0, 45.0)
CALL getdifference(-85.0, 90.0)
CALL getdifference(-95.0, 90.0)
CALL getdifference(-45.0, 125.0)
CALL getdifference(-45.0, 145.0)
CALL getdifference(-45.0, 125.0)
CALL getdifference(-45.0, 145.0)
CALL getdifference(29.4803, -88.6381)
CALL getdifference(-78.3251, -159.036)
CALL getdifference(-70099.74233810938, 29840.67437876723)
CALL getdifference(-165313.6666297357, 33693.9894517456)
CALL getdifference(1174.8380510598456, -154146.66490124757)
END
You may also check:How to resolve the algorithm Boolean values step by step in the Objeck programming language
You may also check:How to resolve the algorithm Rock-paper-scissors step by step in the REXX programming language
You may also check:How to resolve the algorithm Synchronous concurrency step by step in the Ruby programming language
You may also check:How to resolve the algorithm Conway's Game of Life step by step in the VBScript programming language
You may also check:How to resolve the algorithm Find the intersection of two lines step by step in the zkl programming language