PDA

View Full Version : triangle calculation confirmation


hyperzoanoid
2002.06.17, 09:21 AM
hey im back again,
i got a images height that i am using as a hypotenuse
and a number that is how tall the triangle is.

to get the angle at which you have to rotate the image so it is as tall as 'tall', i calculate it this way.

angle=(sin(tall/hypotenuse)*180)/3.14;

but as tall gets bigger the angle increases, and as tall gets smaller the angle decreases. Something wrong?

swcrissman
2002.06.17, 09:38 AM
Hi Hyper. I'm having trouble visualizing what you are calculating here, so if you give a little clarification, maybe I can help.

You have an image that is hypotenuse high, that is oriented right side up, and you are trying to calculate how far you have to rotate it clockwise to get it to the point where it will only be 'tall' above the horizontal baseline? Is that correct?

Really, you need to just clarify which direction you are rotating, and how the image is oriented to begin with, and when the rotation is completed. Then we can try an make sense of your results.

Spencer

jefftkd
2002.06.17, 10:16 AM
angle=(sin(tall/hypotenuse)*180)/3.14;

but as tall gets bigger the angle increases, and as tall gets smaller the angle decreases. Something wrong?
Okay, little trig work here:

sin() is the ratio of height:width of a right triangle.
cos() is the ratio of width:height of a right triangle.

Now, sine = height/hypot. So, when you do: tall/hypot, you already have the sine of the angle -- there is no need to calculate it (and the conversion from degrees to radians is unnecessary as the sine of an angle is a scalar, not an angle itself).

So if you want the angle of a right triangle, and you know the height and hypotenuse, take the arcsine of the sine of the angle:

angle = asin(tall/hypotenuse);

Now, this value will be in radians. So if you want degreed:

angle *= 180.0 / pi;

HTH,
Jeff :cool:

hyperzoanoid
2002.06.17, 10:29 AM
sorry swcrissman, let me try it again ill try and take out the confusion

in a right triangle..
i have a fixed hypotenuse value, lets call it "hypo"
i also have a variable height value, lets call it "tall"

since tall is variable i have to calculate the angle from scratch.
lets assume that the triangle is right side up, and i want to get the lower right angle from the two measurements above.

angle=(sin(tall/hypo)*180)/3.14;

yeah this is exactly what i am trying to do
"you are trying to calculate how far you have to rotate it clockwise to get it to the point where it will only be 'tall' above the horizontal baseline? Is that correct?"

hyperzoanoid
2002.06.17, 10:33 AM
Thanks jeff, i thought that, well nevermind :)