trigonometry · MIT License
Overview
Solve a right triangle from an angle and a side or from two sides, find a height from an angle of elevation and a distance, or find the angle of elevation from a height and a distance.
- Owner-tested on a TI calculator
- Version 1.0.0
- 2201 bytes
- Uses math
Tried it? Did this program work on your calculator?
Before you run it
- TI-84 Plus CE Python · No calculator OS or Python App version has been verified.
- TI Connect CE .py transfer to the Python App; the owner's transfer details were not recorded
- C is the right angle; side a is across from angle A, side b is next to A, and c is the hypotenuse.
- Angles are in degrees, and the angle of elevation is measured from the ground.
- Lengths must be positive numbers, typed as decimals or fractions such as 1/2.
Try the DuckieDai calculator screen
Follow the program's prompts and result flow before downloading.
TI-84 Plus CE Python · screen preview
Learn the math
How to solve right triangles and angle of elevation problems
The idea
Many real problems hide a right triangle: a ladder against a wall, a kite string, the height of a tree from where you stand. Once you sketch the triangle and label it, two facts are enough to find everything else, either an angle and a side or two sides.
An angle of elevation is measured up from the ground to your line of sight. With the distance along the ground as the adjacent side and the height as the opposite side, tangent links the two, so you can find the height from the angle, or the angle from the height.
The formula
sin A = a/c, cos A = b/c, tan A = a/b
a^2 + b^2 = c^2, B = 90 - A
height h = d * tan(A), angle A = tan^-1(h/d)
A, B, C- the angles, with C the right angle
a, b, c- the sides across from A, B, and C, so c is the hypotenuse
angle of elevation- the angle up from the horizontal ground to the top of the object
d- the distance along the ground to the object
Using the program
- Choose 5 first if you need the picture: it shows where A, B, C and a, b, c go, with SOH CAH TOA measured from A.
- Choose 1 when you know angle A and one side. Type A in degrees, pick the side you know, a, b, or the hypotenuse c, and type its length.
- Choose 2 when you know two sides: both legs, a and c, or b and c. The hypotenuse must be the longest side.
- Choose 3 for a height from an angle of elevation and a distance, and 4 for the angle of elevation from a height and a distance. Lengths can be fractions such as 1/2.
Worked example
A right triangle has A = 30 degrees and hypotenuse 10. Choose 1, type 30, choose 3 for c, and type 10.
a = 10 sin 30 = 5, b = 10 cos 30 = 8.66025, B = 90 - 30 = 60
The program shows A = 30 deg, B = 60 deg, a (opp A) = 5, b (adj A) = 8.66025, and c (hyp) = 10.
Legs 3 and 4: choose 2, then 1, and type 3 and 4. The program shows A = 36.8699 deg and B = 53.1301 deg with c (hyp) = 5.
From 120 feet away, the top of a building is at a 35 degree angle of elevation. Choose 3, type 35, then 120. The program shows = 120 * tan(35) and = 84.0249, so the building is about 84 feet above eye level.
You stand 200 feet from a 50 foot pole. Choose 4, type 50 for the height, then 200. The program shows = tan^-1(50/200) and = 14.0362 deg.
Tips and common mistakes
- Draw the triangle before typing anything. Put the angle you know at A, so its opposite side is a and the ground is b.
- The two acute angles add up to 90 degrees, so B = 90 - A is a quick check.
- An angle of elevation gives the height above your eyes. If a problem gives your eye height, add it to the answer.
- An angle of depression, looking down, equals the angle of elevation from the other end, so it uses the same triangle.
Where this comes up
Right triangle applications and angles of elevation are a standard section of precalculus, trigonometry, and geometry, and they come up again in physics with ramps, vectors, and projectiles.
Exact reviewed bytes
Source code
from math import sin,cos,tan,atan,sqrt,pidef clr():print("\n"*11)def pg():input("[enter]");clr()def f(x):return "%.6g"%xdef num(p):while 1:s=input(p).strip()try:if "/" in s:a,b=s.split("/");v=float(a)/float(b)else:v=float(s)if v>0:return vexcept (ValueError,ZeroDivisionError):passprint("Positive number please")def ang(p):while 1:v=num(p)if v<90:return vprint("Must be between 0 and 90")def pick(p,v):while 1:c=input(p).strip()if len(c)==1 and c in v:return cdef show(A,a,b,c):clr();print("A = "+f(A)+" deg\nB = "+f(90-A)+" deg\nC = 90 deg\na (opp A) = "+f(a)+"\nb (adj A) = "+f(b)+"\nc (hyp) = "+f(c));pg()clr();print("4.8 RIGHT TRIANGLES\n __\n ___(o )> quack!\n \\ <_. )\n `---'\nDuckieDai (TM)\nhiddenwordscanner.com");pg()while 1:k=pick("4.8 TRIANGLES\n1 Angle + side\n2 Two sides\n3 Height (elevation)\n4 Angle of elevation\n5 Labels picture\n0 Exit\n> ","012345")clr()if k=="0":breakif k=="1":A=ang("Angle A (deg)? ");s=pick("Known side:\n1 a (opp A)\n2 b (adj A)\n3 c (hyp)\n> ","123");v=num("Length? ");r=A*pi/180if s=="1":a=v;c=v/sin(r);b=v/tan(r)elif s=="2":b=v;c=v/cos(r);a=v*tan(r)else:c=v;a=v*sin(r);b=v*cos(r)show(A,a,b,c)elif k=="2":s=pick("Known sides:\n1 a and b (legs)\n2 a and c\n3 b and c\n> ","123")if s=="1":a=num("a? ");b=num("b? ");c=sqrt(a*a+b*b)else:x=num(("a" if s=="2" else "b")+"? ");c=num("c (hyp)? ")if c<=x:print("Hyp c must be biggest");pg();continuey=sqrt(c*c-x*x)if s=="2":a=x;b=yelse:a=y;b=xshow(atan(a/b)*180/pi,a,b,c)elif k=="3":A=ang("Angle of elev (deg)? ");d=num("Distance along ground? ")h=d*tan(A*pi/180);clr()print("h = d * tan(A)\n = "+f(d)+" * tan("+f(A)+")\n = "+f(h)+"\n(above eye level -\n add eye height if given)");pg()elif k=="4":h=num("Height? ");d=num("Distance along ground? ")A=atan(h/d)*180/pi;clr()print("A = tan^-1(h/d)\n = tan^-1("+f(h)+"/"+f(d)+")\n = "+f(A)+" deg");pg()else:print(" B\n |\\\n | \\\n a | \\ c\n | \\\n |____\\\n C b A\nC = 90, a across from A\nSOH CAH TOA (from A)");pg()print("Quack! DuckieDai (TM)\nhiddenwordscanner.com")
- Filename
RTRI48.py- Size
- 2201 bytes
- SHA-256
559ab8bf72de7af6c1aa6c19ca2afdefa6c2a58d2f507c0a3f7581cdd4ae5c6f
Usage
Inputs
- A menu choice: 1 angle and side, 2 two sides, 3 height, 4 angle of elevation, 5 labels picture, 0 exit
- Angle A in degrees and one known side: a, b, or the hypotenuse c
- Two known sides: both legs, a and c, or b and c
- An angle of elevation and the distance along the ground, or a height and the distance
Outputs
- Angles A, B, and C and sides a, b, and c, to 6 significant digits
- The height h = d * tan(A), with a reminder to add eye height when a problem gives one
- The angle of elevation A = tan^-1(h/d) in degrees
- A labeled right-triangle picture with SOH CAH TOA
Units: Any one length unit for every side; angles in degrees.
Assumptions and limitations
Assumptions
- C is the right angle; side a is across from angle A, side b is next to A, and c is the hypotenuse.
- Angles are in degrees, and the angle of elevation is measured from the ground.
Constraints
- Lengths must be positive numbers, typed as decimals or fractions such as 1/2.
- Angle A must be between 0 and 90 degrees, and the hypotenuse must be longer than the other known side.
Known failures
- Answers are decimals to 6 significant digits, not exact square roots.
- Typing inf as a length is accepted and gives inf or nan in the answers.
Compatibility and review
- Review status
- Owner-tested on a TI calculator
- Tested on
- Owner reports personally running this program on a TI-84 Plus CE Python calculator; the test date, OS version, and Python App version were not recorded
- What happened
- Owner reported pass on the calculator. The published file is the owner's tested source.
- Dependencies
- math
- Suggested calculator name
RTRI48— you can give it another valid, unique name when you transfer it- Desktop test cases
- Not available for this interactive-only source
This exact source auto-launches an interactive calculator session, so compatibility evidence comes from the recorded physical-device review rather than an importable desktop fixture.
Transfer and launch
Download the .py file, send it to your calculator with TI Connect CE as RTRI48 or another name, then open the Python App and try the worked example on this page first. This release has no verified calculator OS or Python App version; treat transfer and execution as unverified until independently tested.
Full installation and troubleshooting guide. Check your teacher's or exam's rules before using any program.
Version history
- 1.0.0 — current version, published . Download this reviewed version
Related learning
Did a DuckieDai program help with your homework? Every program here is free. If you would like to say thanks, you can leave a tip on Cash App ($duckiedai214) or read what tips pay for.
Independent compatibility resource: Hidden Word Scanner is independent and is not affiliated with or endorsed by Texas Instruments. TI product names describe compatibility only.
Action-count privacy: Successful downloads, preview starts, and preview completions increment same-origin aggregate counters, and so does a Yes or No answer about whether the program worked. Your browser notes that you answered; that note is never sent to the site. No entered values, source text, IP address, account, cookie, device identifier, or fingerprint is stored with these counts.