• Welcome to Valhalla Legends Archive.
 

Pythagorean theorem

Started by ObsidianWolf, January 22, 2004, 11:25 AM

Previous topic - Next topic

ObsidianWolf

A squared + B squared = C squared

So in Programming it would be roughly

((A x A) + (B x B))/2 = C Squared?

ObsidianWolf

nm, Solved my own question by looking in earlier posts.  

Pythagoras theorem: c^2 = a^2 + b^2
Trigonometry: c = a/sin(alpha) = b/sin(beta) = a/cos(beta) = b/cos(alpha)

K

#2
And don't forget the law of cosines too!  :P
triangle with sides a, b, c, each side opposite it's respective angle A, B, C.

a2 = b2 + c2 - 2bc*cos(A)

Edit: changed sign.  See reply below.  That's what I get for trying to do things from memory.
Edit2: changed angle.  See further below.  I will now hide myself in shame for even posting to begin with.

Yoni

#3
Close enough, but it's really
a² = b² + c² - 2bc*cos(A)

The sign on the cosine is negative, and the angle in the cosine on the right of the equation is opposite the side that's squared on the left of the equation.

Edit: Note that the Pythagorean theorem can be viewed as a special case of the cosine theorem for A = 90 degrees. (Then cos(A) = 0.)

ObsidianWolf

Will your way produce any more of an accurate answer Yoni?  If so Ill use that instead.

Yoni

A more accurate answer?? This isn't about accuracy or precision, it's a theorem that helps you find an expression for the ratio between parts of the triangle. You should use it if it's useful for what you're trying to solve, or something else if it's not. Accuracy or precision are a different matter, and they don't depend on the way you used to reach the solution.

Btw K, you're still taking the cosine of the wrong angle :P

ObsidianWolf

Im using it to find a value between lat longs.  if the value falls in a certain range then i pass it along to mapper routine.