Re: Survey Problem-QBASIC answer


[ Follow Ups ] [ Post Followup ] [ Previous # Next ] [ Start New Thread ] [ TarBoard ]

Posted by Ed Kiser on September 09, 2003 at 20:49:48 from 152.163.252.103 user Kisered.

In Reply to: Re: Survey Problem posted by John Nichols on September 09, 2003 at 18:47:13:

If the dimensions are provided for the following program, the lengths of the sides and the altitude to the given base is calculated.

QBASIC is needed to execute this.

Hope I didn't mess this one up...

Ed Kiser, South Florida
================================================
'TRIANGLE.BAS
'INDFMT(2,32)
'The figure under study is a triangle, of which two angles
' and the joining side between them are known.
'
'Input: two angles, and the length of the side between them.
' The second angle may be obtuse.
'
'Results: the length of the other two sides.

'In the book, "Secret Water" written by Arthur Ransome, one of their
'projects is to survey and draw a relatively accurate map of the several
'islands in the tidal area. They started off with measuring a baseline
'running along the top of the dyke where their camp was located, then
'took a measurment of the bearings from both ends of that baseline towards
'a farmer's house in the center of the island, as it was a convenient
'point easily viewable from both ends of the dyke. In this situation,
'they started with the ANGLE-SIDE-ANGLE of a triangle, and with this math,
'were able to obtain accurate measurements of the distances to the farmer's
'house. They went on to locate several other observable points around the
'perimeter of the island. Usage of this triangulation method, they were
'able to determine the proper dimensions of that land.

'It all goes to show how educational it was to read these stories by
'Arthur Ransome. It was learning without having to feel like that there
'was something to be learned; it just came automatically while having
'the fun of the adventure of the story. This is all a part of the
'"Magic of Arthur Ransome."

'==============================
'Declarations of variables used:

DIM angleA AS DOUBLE 'first of two known angles
DIM sinA AS DOUBLE 'sin (angle A)

DIM angleB AS DOUBLE 'second of two known angles
DIM sinB AS DOUBLE 'sin (angle B)

DIM supB AS DOUBLE 'supplement of angle B
DIM sinsupB AS DOUBLE 'sin (sup B)

DIM sinAB AS DOUBLE 'sin (angle A + angle B)
DIM sinBA AS DOUBLE 'sin (sup B - angle A)

DIM sideC AS DOUBLE 'length of known baseline
' between the two known angles
DIM h AS DOUBLE 'length of altitude,
' perpendicular to known baseline
DIM sideB AS DOUBLE 'resulting length of line
' opposite the angle B
DIM sideA AS DOUBLE 'resulting length of line
' opposite the angle A

'==============================
'Definitions of the CONSTANTS used:

CONST PI = 3.141592654#
CONST FMT = "&####.##" 'format of results display

'conversion of DEGREES to RADIANS:
CONST DEGTORAD = (PI / 180#) 'radians = degrees * (PI / 180)

'==============================
'Start of executable portion code:

CLS 'clear the screen

DO 'repeat until legal angles specified
: DO 'repeat until first angle is in range
: : PRINT "The first angle to be specified must be in the range of:"
: : PRINT " 0 < angle A < 90 degrees."
: : INPUT "In DEGREES, specify angle A: "; angleA
: LOOP UNTIL ((0 < angleA) AND (angleA < 90))

: DO 'repeat until second angle is in range
: : PRINT
: : PRINT "The second angle to be specified has a larger range of:"
: : PRINT " 0 < angle B < 180 degrees."

: : INPUT "In DEGREES, specify angle B: "; angleB
: : supB = 180 - angleB 'find the supplement to angle B
: LOOP UNTIL ((0 < angleB) AND (angleB < 180))

'If second angle is obtuse, be sure it is ok with acute first angle
: IF ((angleB <= 90) OR (angleA < supB)) THEN
: : EXIT DO 'go with values we have so far

: ELSE 'this is not valid
: : PRINT
: : PRINT "Incorrect angles specified; "
: : PRINT " No triangle results."
: : PRINT "Start over with both angles..."
: : PRINT
: END IF

LOOP 'start over with new angles

PRINT
INPUT "Specify the length of the side between angle A and B: "; sideC

sinA = SIN(angleA * DEGTORAD)

IF (angleB <= 90) THEN 'if second angle is acute
: sinB = SIN(angleB * DEGTORAD)
: sinAB = SIN((angleA + angleB) * DEGTORAD)
: h = sideC * ((sinA * sinB) / sinAB)'get altitude to known baseline

: sideA = h / sinB
ELSE 'since angleB is obtuse (> 90)
: sinsupB = SIN(supB * DEGTORAD)
: sinBA = SIN((supB - angleA) * DEGTORAD)
: h = sideC * ((sinA * sinsupB) / sinBA)

: sideA = h / sinsupB
END IF
sideB = h / sinA

PRINT
PRINT USING FMT; "Side B is "; sideB;
PRINT USING FMT; " and side A is "; sideA

PRINT USING FMT; "Altitude perpendicular to base line is "; h
SYSTEM 'return to the Operating System
'===============================
'REFERENCE: P346 "CRC Standard Mathematical Tables" - Tenth Edition
'copyright 1954, by the Chemical Rubber Company
'----------End of TRIANGLE.BAS---------




Follow Ups:



Post a Followup

Name:
Eel-Mail:

Existing subject (please edit appropriately) :

Comments:

Optional Link URL:
Link Title:
Optional Image URL:

post direct to TarBoard test post first

Before posting it is necessary to be a registered user.


[ Follow Ups ] [ Post Followup ] [ TarBoard ]

Courtesy of Environmental Science, Lancaster

space