Click here to Skip to main content
16,015,094 members
Home / Discussions / Algorithms
   

Algorithms

 
AnswerRe: RSA Pin
Sebastian Schneider10-Nov-06 3:00
Sebastian Schneider10-Nov-06 3:00 
AnswerRe: RSA Pin
Bagaturia david15-Nov-06 21:56
Bagaturia david15-Nov-06 21:56 
QuestionCosting terrain paths Pin
Kevnar8-Nov-06 8:56
Kevnar8-Nov-06 8:56 
AnswerRe: Costing terrain paths Pin
ejuanpp9-Nov-06 0:40
ejuanpp9-Nov-06 0:40 
GeneralRe: Costing terrain paths [modified] Pin
Kevnar9-Nov-06 2:53
Kevnar9-Nov-06 2:53 
GeneralRe: Costing terrain paths Pin
ejuanpp9-Nov-06 3:21
ejuanpp9-Nov-06 3:21 
GeneralRe: Costing terrain paths [modified] Pin
Kevnar9-Nov-06 3:40
Kevnar9-Nov-06 3:40 
GeneralRe: Costing terrain paths Pin
ricecake9-Nov-06 4:09
ricecake9-Nov-06 4:09 
Just remember your trig functions:
    /|
 h / |
  /  | o
 /   |
/ θ  |
------
   a
I remember them with the mnemonic SOHCAHTOA:
SOH -> sin(θ ) = opposite / hypotenuse
CAH -> cos(θ ) = adjacent / hypotenuse
TOA -> tan(θ ) = opposite / adjacent

Then, to find the angle, you can use the inverse trig functions:
θ = asin(opposite / hypotenuse) = acos(adjacent / hypotenuse) = atan(opposite / adjacent)

In standard Cartesian coordinates, if the triangle is oriented as above with the origin located where θ is, then the adjacent side (a) is x, and the opposite side (o) is y. So, since you usually know x and y, there is no need to calculate the hypotenuse to find the angle, since you can then do θ = atan(y/x).

Be aware that the above identities are true only for radian angles. If you need degrees, then you must convert at the end using the identity 180 degrees = π (should be a pi, but it looks funny in my font) radians.

--
Marcus Kwok

GeneralRe: Costing terrain paths Pin
Kevnar9-Nov-06 4:16
Kevnar9-Nov-06 4:16 
GeneralRe: Costing terrain paths Pin
ricecake9-Nov-06 4:37
ricecake9-Nov-06 4:37 
GeneralRe: Costing terrain paths [modified] Pin
Kevnar9-Nov-06 5:24
Kevnar9-Nov-06 5:24 
GeneralRe: Costing terrain paths Pin
ricecake9-Nov-06 5:48
ricecake9-Nov-06 5:48 
GeneralRe: Costing terrain paths Pin
Kevnar9-Nov-06 6:05
Kevnar9-Nov-06 6:05 
GeneralRe: Costing terrain paths Pin
ricecake9-Nov-06 6:46
ricecake9-Nov-06 6:46 
GeneralRe: Costing terrain paths Pin
Kevnar9-Nov-06 7:14
Kevnar9-Nov-06 7:14 
GeneralRe: Costing terrain paths Pin
ricecake9-Nov-06 7:21
ricecake9-Nov-06 7:21 
GeneralRe: Costing terrain paths Pin
Kevnar9-Nov-06 7:31
Kevnar9-Nov-06 7:31 
GeneralRe: Costing terrain paths Pin
ejuanpp9-Nov-06 3:43
ejuanpp9-Nov-06 3:43 
GeneralRe: Costing terrain paths Pin
Kevnar9-Nov-06 4:13
Kevnar9-Nov-06 4:13 
QuestionBeginners question? Where does the exact double value go? Pin
ClockDivider8-Nov-06 6:48
ClockDivider8-Nov-06 6:48 
AnswerRe: Beginners question? Where does the exact double value go? Pin
Rob Graham8-Nov-06 7:09
Rob Graham8-Nov-06 7:09 
GeneralRe: Beginners question? Where does the exact double value go? Pin
Dan Neely8-Nov-06 7:24
Dan Neely8-Nov-06 7:24 
GeneralRe: Beginners question? Where does the exact double value go? Pin
ClockDivider8-Nov-06 8:15
ClockDivider8-Nov-06 8:15 
QuestionScaling - help me Pin
dharani7-Nov-06 0:06
dharani7-Nov-06 0:06 
AnswerRe: Scaling - help me Pin
Jörgen Sigvardsson7-Nov-06 13:02
Jörgen Sigvardsson7-Nov-06 13:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.