# Calculating triangle side length based on hypotenuse?

 0 Essentially as part of my application the sides of a triangle are calculated much like the first part of the attached image. This is done using a simple distance function. However later in the application the triangle can be scaled (1 to 1 so it remains the same shape), I continue knowing the distance (hypotenuse) but not the side edges, I've had real trouble allowing my application to calculate the side edges (part 2 of the diagram). If anyone could help then it would be greatly appreciated. I've attempted using basic Pythagorus (b^2 = c^2 - a^2) but my application struggles with it and responds with "NaN". For those who are interested I'm essentially building a "Scroll wheel" into my application where an object follows your finger when it's on the scroll wheel. When it's off of the scroll wheel it still follows it but only to the edge of the circle where it then stops. So if you drag your finger around the edge of the circle then it follows it round but only to the edge of the circle. EDIT: I've attempted the following but it doesn't work. It's set inside a block that says if distance is greater than 40 then do this: ``````var AngleVar = ((Vector3.Angle(Vector3(Ball.position.x,Ball.position.y, 0), Vector3(MoveDist.x, MoveDist.y, 0)))/180); Target2.position = Vector3((40 * Mathf.Cos(AngleVar)), (40 * Mathf.Sin(AngleVar)), Target2.position.z); `````` It doesn't limit the distance to 40 like it should and the rotation is not correct either. AngleVar is calculated correctly. When it's directly above "Ball" (Wheel centre) it is 1 and when directly below it is 0. I realise that Sin and Cos will flip round as I move around the circle but this code is not working an any segment. more ▼ asked Aug 05 '10 at 02:12 PM ROM 262 ● 46 ● 49 ● 58 SisterKy 2.4k ● 33 ● 41 ● 59 This is pretty basic, if you know the angle of the triangle you can use trigonometry to find the other sides or if you're using vectors it's a simple case of subtraction. What script did you use to get that error? Aug 05 '10 at 02:18 PM spinaljack I'm not using vectors so unfortunately that will not work. I tried your solution. The results are above. I'm sure I've done something wrong ^-^ Aug 05 '10 at 02:40 PM ROM I'm having trouble figuring out what your code is doing exactly.. what is this Ball? and what is MoveDist? Trig can be a bit wonky, but if you can give us a better sense of your code I can definitely help you solve this one.In general terms you say you know all of the original sides of the triangle... and thus can find Theta (the angle of the triangle between the adjacent and hypotenuse). Make use of SOH CAH TOA (Sin(Theta) = opposite/hypotenuse etc) to find Theta for the original triangle, and then scale it appropriately... and use the Hypotenuse length and this known Theta to clone the tri Aug 05 '10 at 03:05 PM DavidB add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

1 answer: sort voted first
 0 Not entirely sure what the issue is here - you're scaling the triangle, can't you just scale the values too? Multiply the values from the left triangle by 30/58.0 (Hypotenuse2/Hypotenuse1) and you get the right triangle values Example using the standard 3 4 5 triangle: 1) Hypotenuse: 5, Opposite: 3, Adjacent: 4 2) Hypotenuse: 10 To get the Opposite and Adjacent values: Opposite = 3 * 10/5 = 6 Adjacent = 4 * 10/5 = 8 Which matches with a 6 8 10 triangle like you'd expect more ▼ answered Aug 05 '10 at 03:07 PM Mike 3 30.5k ● 10 ● 65 ● 253 add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users
Your answer

### Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x211
x35
x33

asked: Aug 05 '10 at 02:12 PM

Seen: 2063 times

Last Updated: Aug 05 '10 at 02:52 PM