Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
Angle of a line...
Author Message
Homer_simpson

Posted: Tue Jul 01, 2003 5:24 pm   Post subject: Angle of a line...

how do i calculate angle A knowing that line1 is always horizontal and having the coordinates of line2...
i know it has to be done using Sine and Cosine but i dont exactly know how....

Haven't had math in while so i've forgotten a few stuff... =/

math.JPG
Description:
Filesize:  7.86 KB
Viewed:  7601 Time(s)

Catalyst

Posted: Tue Jul 01, 2003 5:40 pm   Post subject: (No subject)

SOH CAH TOA

sin=op/hyp

your hyp is the distance from point1 to point2
since line 2 is always horizontal that distance is y2-y1

angle=sin-1((y2-y1)/distance (p1,p2))
Andy

Posted: Tue Jul 01, 2003 5:40 pm   Post subject: (No subject)

since tan of an angle is the oposite side over the adjancent side, you simply set up an equation of tan(x)=10/20 tan(x)=1/2 then u juss do tan inverse and you get 45 degrees
SilverSprite

Posted: Tue Jul 01, 2003 6:07 pm   Post subject: (No subject)

yepyep just something to add.. since tan is opposite side over adjacent side.. that means that it is simply the slope of the line meaning that tanA where A is the required angle is equal to the slope of the line.. so A = arctand(slope of line)
Homer_simpson

Posted: Tue Jul 01, 2003 6:44 pm   Post subject: (No subject)

hmmm.... got it!!! thx...
here's another question how do i caculate tangent (a) in Turing?
Andy

Posted: Tue Jul 01, 2003 6:53 pm   Post subject: (No subject)

there is no tangent in turing, but since tan(A)=sin(A)/cos(A) just substitute it
Homer_simpson

Posted: Tue Jul 01, 2003 6:58 pm   Post subject: (No subject)

no it's not i thought of that and i tried it b4 it doesn't work !!! =(
Edit:oh wait nvm i used cos instead of cosd now it works...

 code: function tan (r : real) : real     result (sind (r) / cosd (r)) end tan put tan (1)

how do i do arctan or sine-1? **-1 doesn't work =/
AsianSensation

Posted: Tue Jul 01, 2003 8:52 pm   Post subject: (No subject)

funny thing is, the geniuses who made turing(tom) decided not to put a inverse cos and sin function, said it was irrelevant.

so the best bet for using inverse tan is to make one urself....

Catalyst

Posted: Tue Jul 01, 2003 9:09 pm   Post subject: (No subject)

such an old post (this is also in the help file)

http://www.compsci.ca/bbs/viewtopic.php?t=263&highlight=inverse
AsianSensation

Posted: Tue Jul 01, 2003 9:19 pm   Post subject: (No subject)

*stick foot in mouth

whoa, they had an arctan function? damn.......Im ignorant.......
Andy

Posted: Tue Jul 01, 2003 9:43 pm   Post subject: (No subject)

wow that's really cool... make ur own inverse functions
SilverSprite

Posted: Tue Jul 01, 2003 11:46 pm   Post subject: (No subject)

its math dodge.. you go to massey you should undetrstand those..
Homer_simpson

Posted: Wed Jul 02, 2003 12:00 am   Post subject: (No subject)

i didn't know they had arctan tangent in turing either... in fact that was all that i needed...
so here's how it goes:
 code: View.Set ("offscreenonly") var x1, x2, y1, y2, b := 0 var slope, ang : real x1 := 100 y1 := 100 loop     mousewhere (x2, y2, b)     drawline (0, y1, 640, y1, 12)     if not (x2 = x1) then         slope := (y2 - y1) / (x2 - x1)     end if     ang := arctand (slope)     locate (1, 1)     put "coords : ", x1, "/", y1, "/", x2, "/", y2     put "slope : ", slope     put "angle :", ang     drawline (x1, y1, x2, y2, 9)     delay (5)     View.Update     cls end loop
Catalyst

Posted: Wed Jul 02, 2003 12:15 am   Post subject: (No subject)

there some problems there
such as the negative angles and the fact and from 180 to 270 show as 0-90
Homer_simpson

Posted: Wed Jul 02, 2003 12:37 am   Post subject: (No subject)

lol well yeah... but it is fixable if you try to fix it... i have fixed it and used it in my new particle engine with gravity support which i'll upload in a few minutes...
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 2  [ 29 Posts ]
Goto page 1, 2  Next
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: