Computer Science Canada

Angle of a line...

Author:  Homer_simpson [ 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....
Posted Image, might have been reduced in size. Click Image to view fullscreen.

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

Author:  Catalyst [ Tue Jul 01, 2003 5:40 pm ]
Post 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))

Author:  Andy [ Tue Jul 01, 2003 5:40 pm ]
Post 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

Author:  SilverSprite [ Tue Jul 01, 2003 6:07 pm ]
Post 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)

Author:  Homer_simpson [ Tue Jul 01, 2003 6:44 pm ]
Post subject: 

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

Author:  Andy [ Tue Jul 01, 2003 6:53 pm ]
Post subject: 

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

Author:  Homer_simpson [ Tue Jul 01, 2003 6:58 pm ]
Post 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 =/

Author:  AsianSensation [ Tue Jul 01, 2003 8:52 pm ]
Post 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....

Author:  Catalyst [ Tue Jul 01, 2003 9:09 pm ]
Post subject: 

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

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

Author:  AsianSensation [ Tue Jul 01, 2003 9:19 pm ]
Post subject: 

*stick foot in mouth

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

Author:  Andy [ Tue Jul 01, 2003 9:43 pm ]
Post subject: 

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

Author:  SilverSprite [ Tue Jul 01, 2003 11:46 pm ]
Post subject: 

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

Author:  Homer_simpson [ Wed Jul 02, 2003 12:00 am ]
Post 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

Author:  Catalyst [ Wed Jul 02, 2003 12:15 am ]
Post subject: 

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

Author:  Homer_simpson [ Wed Jul 02, 2003 12:37 am ]
Post 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...

Author:  Andy [ Wed Jul 02, 2003 9:25 am ]
Post subject: 

SilverSprite wrote:
its math dodge.. you go to massey you should undetrstand those..

sorry silversprite that i'm not as smart as you plus i suck at turing, i didn't even know about arctan

Author:  SilverSprite [ Wed Jul 02, 2003 11:13 am ]
Post subject: 

dodge_tomahawk wrote:
... i suck at turing, i didn't even know about arctan

omg GEEK Razz

Author:  Andy [ Thu Jul 03, 2003 9:51 am ]
Post subject: 

? how does that work... ur calling me a geek cause i don't spend time programming?

Author:  SilverSprite [ Thu Jul 03, 2003 1:47 pm ]
Post subject: 

nope.. just cuz you find it your duty or a need to memorize all turing commands... like it'll matter

Author:  krishon [ Thu Jul 03, 2003 4:32 pm ]
Post subject: 

lol, silversprite's got a point there

Author:  Andy [ Thu Jul 03, 2003 5:13 pm ]
Post subject: 

no i was simply admitting that i'm not some compsci wiz

Author:  SilverSprite [ Thu Jul 03, 2003 5:31 pm ]
Post subject: 

krishon wrote:
lol, silversprite's got a point there

thx krishon.. its the truth lol
dodge_tomahawk wrote:
no i was simply admitting that i'm not some compsci wiz

you sure do an excessive amount of compsci.. and your still not a wiz?
dodge_tomahawk wrote:
? how does that work... ur calling me a geek cause i don't spend time programming?

i'm just playing around with you dodge.. you know me.. dont take it personally jkjkjkJK

Author:  Andy [ Thu Jul 03, 2003 5:39 pm ]
Post subject: 

hey man ever heard of china man dun understand sarcasm?

Author:  SilverSprite [ Thu Jul 03, 2003 5:49 pm ]
Post subject: 

nope and dont care

Author:  Homer_simpson [ Thu Jul 03, 2003 6:03 pm ]
Post subject: 

This discussion is giong off topic and getting stupid again... so just stop here...

Author:  Andy [ Thu Jul 03, 2003 7:01 pm ]
Post subject: 

well we finished answering ur question didn't we?

Author:  Homer_simpson [ Thu Jul 03, 2003 7:36 pm ]
Post subject: 

well then i dont see reason to start a new nonsense discussion and spam the forum...

Author:  JSBN [ Thu Jul 03, 2003 11:58 pm ]
Post subject: 

This reminds me, does any1 still want those trajectory formulas?

Author:  JayLo [ Fri Jul 04, 2003 12:07 am ]
Post subject: 

yes, please.


: