Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Right Triangle Algorythms
#1
I've been writing a script that basically creates a building in TS7 all by itself. But I ran into a bunch of road blocks but figured out the math and figured I would share a few formulas with everyone to help solve some problems that I know I've been trying to figure out and finally did.

A Right Triangle is a tringle that has one 90 degree corner. The side away from the lowest angle corner is called the Opposite, the side 90 degrees from that is the Adjacent and the longest side is the Hypotenuse. Now just knowing one or two of these dimensions you can calculate and find all the rest of the dimensions of that triangle (these formulas come in handy for all kinds of uses)... here's a diagram:

[Image: righttri.gif]

a = Opposite
b = Adjacent
c = Hypotenuse

To find any of the side lengths knowing the lengths of the other two sides you use the following formulas in QM

Code:
Copy      Help
double Opp, Adj, Hyp, AngA, AngB  ;; This is where we get the results
double O, A, H, Aa, Ab, Tmp       ;; We'll use these for our temporary known values

;// We'll set up the temp values for examples.
O = 15.00
A = 25.00
H = 29.15
Aa = 30.96
Ab = 59.04
def PI 3.1415926535897932384626433832795

Hyp  = sqrt((O*O)+(A*A)) ;; Hyp = Square Root of Opp squared plus Adj squared
Opp  = sqrt((H*H)-(A*A)) ;; Opp = Square Root of Hyp squared minus Adj squared
Adj  = sqrt((H*H)-(O*O)) ;; Adj = Square Root of Hyp squared minus Opp squared

AngA = asin(Opp/Hyp)*180/PI ;; use this if the Opp and Hyp are the only known dimensions
AngA = acos(Adj/Hyp)*180/PI ;; Use this if the Adj and Hyp are the only known dimensions
AngA = atan(Opp/Adj)*180/PI ;; Use this if the App and Adj are the only known dimensions

AngB = 90-AngA

Opp  = Round(Opp 2)
Adj  = Round(Adj 2)
Hyp  = Round(Hyp 2)
AngA = Round(AngA 2)
AngB = Round(AngB 2)

out F"The Opposite   = Original {O} : Calculated {Opp}"
out F"The Adjacent   = Original {A} : Calculated {Adj}"
out F"The Hypotenuse = Original {H} : Calculated {Hyp}"
out F"The Angle A    = Original {Aa} : Calculated {AngA}"
out F"The Angle B    = Original {Ab} : Calculated {AngB}"

Go ahead and use these with your own values and hopefully I've helped someone! Enjoy!


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)