wood burning stoves 2.0*
The moose likes Programming Diversions and the fly likes Triangles! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Other » Programming Diversions
Bookmark "Triangles!" Watch "Triangles!" New topic
Author

Triangles!

Nick George
Ranch Hand

Joined: Apr 04, 2004
Posts: 815
A pretty straight forward, but interesting, one regarding a traingle as follows:

In triangle ABC, AB=4, AC=6, AD=5, where D is the midpoint of BC. What is BC?


I've heard it takes forever to grow a woman from the ground
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
c1^2 + c2^2 = 5^2 + 5^2 - 4^2 - 6^2
Arjun Shastry
Ranch Hand

Joined: Mar 13, 2003
Posts: 1871
Cosine rule for two triangles:ABD and ABC
cos B = a**2+c**2-b**2/2*a*c
gives BC = 2.
[ June 05, 2004: Message edited by: Ram Abdullah D'Souza ]

MH
Nick George
Ranch Hand

Joined: Apr 04, 2004
Posts: 815
Well, that looks like the right answer, howerver, i am a bit lost as to how it is obtained. Using law of cosines, I was able to get the following three equations from the three triangles:

s=length of BD (half of BC)
beta1+beta2=angle BAC

4s�=52-48cos(beta1+beta2)

s�=41-40cos(beta1)

s�=61-60cos(beta1)

after solving all three together, i found s to be something like 1.223.

can i have a little more explanation as to how you came at your answers?
Arjun Shastry
Ranch Hand

Joined: Mar 13, 2003
Posts: 1871
We can apply cosine rule only to two triangles.namely,ABD and ABC.
Let 2x be length of BC.then BD=DC = x.
For triangle,ABD,
cosB = (4*4+x*x-5*5)/2*4*x-----------(1)
For triangle ,ABC
cosB = (4*4+(2x*2x)-6*6)/2*4*2x--------(2)
Equating 1 &2 ,will give x=1-->BC=2
Nick George
Ranch Hand

Joined: Apr 04, 2004
Posts: 815
quite understood... Thanks!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Triangles!
 
Similar Threads
Difference in equals() method and comparision operator
10,000 B.C.
My interview questions
How to pass Java value from program
which city would you rather live in?