TIP: Click on subject to list as thread! ANSI
echo: quik_bas
to: HARRY HICKEY
from: DAVID WILLIAMS
date: 1998-04-29 18:48:00
subject: Help needed (geometry cod

-> You know, of course, that the slope of the line from vertex 1 to
-> vertex 2 is given by (y2-y1)/(x2-x1). We will call this slope s12:
-> s12 = (y2 - y1)/(x2 - x1) And the slope from vertex 1 to vertex 3 is:
-> s13 = (y3 - y1)/(x3 - x1) And the angle you want is:
-> Angle = ATAN(s12) - ATAN(s13) Take the tangent of both sides (consult
-> any trig textbook) and you get: TAN(Angle) = p / q     where p = (y2
-> - y1) * (x3 - x1) - (y3 - y1) * (x2 - x1) q = (y3 - y1) * (x3 - x1) -
-> (y2 - y1) * (y3 - y1) So now, in your program, you will want to
-> initialize early on to get as precise a value of pi / 2 as possible:
-> HalfPi = 2 * ATAN (1.0) -- then, in your triangle-solving loop, you
-> write:
-> IF q0 THEN  Angle = ATAN (p / q)
-> ELSE  IF p > 0 THEN
->     Angle = HalfPi
->   ELSE
->     Angle = - HalfPi
->   ENDIF
-> ENDIF
A further little thought. Your method calculates the angle between the
two sides, but it loses track of where the triangle lies. Unless the two
lines are perpendicular, the angle between them can be expressed either
as an acute angle or an obtuse one, the two adding up to pi radians. As
far as I can see, there is no way to tell, from your method, which of
these two possibilities is the correct answer.
Am I right?
                             dow
--- QScan/PCB v1.19b / 01-0150
---------------
* Origin: Pro-Mail Communications - Toronto Canada (1:250/1004)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.