BBS: Inland Empire Archive Date: 01-03-93 (01:03) Number: 261 From: DIK COATES Refer#: NONE To: JOHN GALLAS Recvd: NO Subj: Re: calculations.. Conf: (2) Quik_Bas
>>>> QUOTING John Gallas to All <<<<
JG> I need some help with some calculations I have to do. Lets
Consider the following code:
- - - - - - - - - - - - Cut Along Dotted Line - - - - - - - - -
DO
CLS
PRINT " y"
PRINT " | (1550,1438)"
PRINT " | X "
PRINT " |"
PRINT " |---->"
PRINT " | POS"
PRINT " -----+------------- x "
PRINT " |"
LOCATE 25, 25
PRINT "Enter Angle = 999 to Quit";
LOCATE 6, 40
PRINT "Enter the Distance: ";
LOCATE 4, 40
INPUT ; "Enter the Angle: ", angle
LOCATE 6, 40
INPUT ; "Enter the Distance: ", dist
radian = angle * .0174533
'convert angle to radians
xcoord = dist * SIN(radian)
ycoord = dist * COS(radian)
'assuming point for offset is x=1550 and y=1438
offx = 1550
offy = 1438
LOCATE 13, 30
PRINT "The X-Coord component is: "; xcoord
LOCATE 14, 30
PRINT "The Y-Coord component is: "; ycoord
LOCATE 15, 30
PRINT "The X-Coord offset from (1550,1438) is: "; offx + xcoord
LOCATE 16, 30
PRINT "The Y-Coord offset from (1550,1438) is: "; offy + ycoord
dummy$ = INPUT$(1)
LOOP UNTIL angle = 999
CLS
PRINT " y (x2,y2) finish"
PRINT " | (600,650)"
PRINT " | X "
PRINT " |"
PRINT " | X"
PRINT " | (500,500)"
PRINT " | ^ (x1,y1) start"
PRINT " | POS |"
PRINT " -----+------------- x "
PRINT " |"
LOCATE 12, 30
x1 = 500
y1 = 500
x2 = 600
y2 = 650
PRINT "The difference in X-coords is x2 - x1: "; x2 - x1;
LOCATE 13, 30
PRINT "The difference in Y-coords is y2 - y1: "; y2 - y1
LOCATE 14, 30
PRINT "The distance between P1 and P2 is: "; SQR((y2 -
y1) ^ 2 + (x2 - x1) ^ 2)
rangle = ATN((y2 - y1) / (x2 - x1))
dangle = rangle * 57.29578
LOCATE 15, 30
PRINT "The Angle from P1 to P2 is: "; rangle; "radians";
LOCATE 16, 30
PRINT "The Angle from P1 to P2 is: "; dangle; "degrees";
LOCATE 18, 10
PRINT "Note the shift in the angle measure; +ve is
counter-clockwise from the X-axis"
END
- - - - - - - - - - - - Cut Along Dotted Line - - - - - - - - -
Trust this is the info required...
Regards Dik, Oshawa, Canada
... And the Gynecologist said, "Great OS too!" -Dik
___ Blue Wave/QWK v2.10
--- Maximus 2.00
* Origin: Durham Systems (ONLINE!) (1:229/110)

Books at Amazon:
Back to BASIC: The History, Corruption, and Future of the Language
Hackers: Heroes of the Computer Revolution (including Tiny BASIC)
Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution
The Advent of the Algorithm: The Idea that Rules the World
Moths in the Machine: The Power and Perils of Programming
Mastering Visual Basic .NET