# Stupid traingle side length question

This topic is 4221 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

This is not homework, although I had it as homework years ago. I should find it easy but i'm rusty and gone blank!
.
. .
.  .
.    . length h = 100
d  .     .
.      .
. H     .
.........
x

I have a triangle. The longest side a is 100, opposite angle H = 3PI/4. I know the length d and want to find out the length x. Now I have: h^2 = x^2 + d^2 - 2dx.cosH Giving a quadratic in x: x^2 - 2d.cosH.x + (d^2-h^2) = 0 The two roots of this are: x = [ -b +/- SQRT( b^2 - 4ac ) ] / 2a Where a=1, b=-2d.cosH, c= d^2 - 10000 But for the life of me I can't figure out if I want the + or the - answer!

##### Share on other sites
If I had to guess(and I do) I'd say you want the plus answer because the minus answer might give you a negative length, but why don't you just write a small program( or maybe just try some examples out on paper) to see which gives you reasonable results.

##### Share on other sites
cosH < 0, => b > 0, and a > 0, and sqrt(delta) > 0

if you use the '-', the result will be always negative. So it's the +.

although, the '+' does not garantee you a positive result either.

##### Share on other sites
I may be missing something, but couldn't you just use trig triangle identities? Specifically, the law of tangents: http://en.wikipedia.org/wiki/Law_of_tangents

##### Share on other sites
He was using trig triangle identities specifically the law of cosines. The law of tangents takes two angles and 2 sides where the law of cosines takes 3 sides and one angle which is what he had so it makes sense to use the law of cosines.

I suspected the negative length thing, but I didn't have time to give a thorough response and prove it(to myself mostly). It still annoys me some that this problem could have been solved fairly easily by looking at a couple of examples on paper and it didn't really need to be posted.

##### Share on other sites
I spent about an hour trying to work it out but kept screwing up. Would you like me to scan that in?

Anyway, if there's better way to solve this that doesn't require solving a quadratic someone plase tell me!

##### Share on other sites
It's the positive square root you require... the explanation is very simple (the proof is trivial too and based on the Triangle Inequality for normed vector spaces).

After rearranging the roots of x you find that you have:

x = d( cos(H) ± Ö( cos2(H) + h2/d2 -1 ) )

If you consider the magnitude of cos(H) versus Ö( cos2(H) + h2/d2 -1 ) you can see that the latter term is of greater magnitude, because h2/d2 > 1. Hence, to avoid a negative distance, you must take the positive square root!

Cheers,

Timkin

[Edited by - Timkin on January 29, 2007 6:07:43 PM]

##### Share on other sites
Just FYI, you can come up with solutions using only permutations of sin, cos and their inverses (think of ways to exploit right-triangles). The quadratic form is a much more succinct numeric solution though.

1. 1
2. 2
JoeJ
20
3. 3
4. 4
5. 5
frob
13

• 9
• 10
• 13
• 9
• 23
• ### Forum Statistics

• Total Topics
632195
• Total Posts
3004712

×

## Important Information

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!