Re: Calculating Angles

 BBS: Inland Empire Archive
Date: 06-25-92 (07:22)             Number: 1336
From: FRANCOIS ROY                 Refer#: NONE
  To: MIKE THAYER                   Recvd: NO  
Subj: Re: Calculating Angles         Conf: (2) Quik_Bas
 MT> DRAW "S4 TA"+STR$(Angle%)  'Use an angle

 The mathematical solution says that the angle, given two points at
 (x1%,y1%) and (x2%,y2%) is given by ATN((y2% - y1%) / (x2% - x1%)).

 There are a few problems to watch out for:

 - the angle returned by ATN() is in radians.  To get degrees, compute:
   Degrees% = Radians% * 180 / 3.141592654

 - the formula assumes that x2% is always greater than x1% (i.e. the point
   that is further to the LEFT is always (x1%,y1%), so that returned angles
   are in the range (-90 degrees to 90 degrees).

 - when x1% and x2% are equal, the line is vertical, so the angle is plus
   or minus 90 degrees.  The formula as given above would give a division
   by 0, so watch that case.

 - screen modes other than SCREEN 11 and 12 do not respect the 4/3 visual
   aspect ratio of the screen (i.e. a pixel is not round but oval in the
   vertical direction) so the calculated angles may not look visually correct.

--- ME2_1104
 * Origin: Out of String Space - the Final Frontier (Fidonet 1:163/506.2)
Outer Court
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