views:

635

answers:

4

I know I should do my homework on my own but I simply cant get my homework to work the way I want it to:

from __future__ import division
import turtle
import math

def triangle(c,a,b,beta,gamma):
    turtle.forward(c)
    turtle.right(180+beta)
    turtle.forward(a)
    turtle.right(beta)
    turtle.left(beta+gamma)
    turtle.forward(b)
    turtle.left(beta+gamma)

def general_abc(a,b,c):
    alpha = math.degrees(math.acos(a/c))
    print alpha
    beta = math.degrees(math.asin(b/c))
    print beta

general_abc(50,60,90)

The function general_abc is supposed to calculate the degrees of the angles when knowing all 3 sides. I am mainly searching for the math behind it. With lots of googling I just don't seem to find the right keywords to use. Please tell me the formulas I have to look into..

+6  A: 

I think what you're looking for is the Law of Cosines, using acos and asin like you are presumes a right triangle.

gct
Thanks darn it :D
Thomaschaaf
I was going to suggest Law of Sines: http://en.wikipedia.org/wiki/Law_of_sines
jeffamaphone
+1  A: 

you can use law of cosines: c² = a² + b² - 2abcos(alpha)

Diego Dias
A: 

Old Indian Chief (as I was taught):

SohCahToa

Sine = Opposite/Hypoteneuse
Cosine = Adjacent/Hypoteneuse
Tangent = Opposite/Adjacent

dcpking
I was taught that mnemonic as well. It works, but only for right triangles. Need to use the cosine law for the general case.
Fred Larson