|
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:
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.
(comments are locked)
|
|
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
(comments are locked)
|


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?
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 ^-^
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