# Calculating Angles

``` BBS: Inland Empire Archive
Date: 06-27-92 (16:39)             Number: 1508
From: FRANKLIN BEAL                Refer#: NONE
To: MIKE THAYER                   Recvd: NO
Subj: Calculating Angles             Conf: (2) Quik_Bas```
```MT>          Frog\$="U3 R6 D6 R6 U3"
>          'Calculate the range between the two points

MT>          Range%=INT((SQR((X1Cord-X2Cord)^2)+((Y1Cord-Y2Cord)^2)))

MT>          'Then when I need to draw the line:
>          PSET (X1Cord,Y1Cord),0  'Find the start point
>          DRAW "S4 TA"+STR\$(Angle%)  'Use an angle
>                                     'I use scale 4 since it best
>                                     'approximates true length
>          For I= 1 to Range%      'The length isn't exact but I'm
>              DRAW Frog\$          'working on that!
>          NEXT I

MT>        The Problem is in figuring the angle. Does anyone know of a
> way to calculate an angle given two points on the screen? That is if
> we can assume that horizon is 0 degrees?

Using the coordinates above, the solution to your problem is associated
with first generating the length and height figures for a right triangle.
You can then apply basic trig. to find the TAN of the angle Theta.
The following will do it for you.
'---------------------------- cut -----------------------------

Length = ABS(X1Cord - X2Cord) 'Get the absolute Length of the baseline
Height = ABS(Y1Cord - Y2Cord) 'Get the absolute Height of the triangle

tanA = Height / Length       'tangent of the angle
angleA = ATN(tanA)           'find the angle by using ArcTangent
'---------------------------- cut ----------------------------
:-)

* SLMR 2.0 * I'm not an actor, but I play one in congress.

--- WM v2.03/91-0012
* Origin: Com-Dat BBS  Hillsboro, OR.  HST (503) 681-0543 (1:105/314)
``` Echo Basic Postings

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