
Annie W.
asked 11/01/20python geometry help
Simple geometry can compute the height of an object from the object's shadow length and shadow angle using the formula: tan(angleElevation) = treeHeight / shadowLength. Given the shadow length and angle of elevation, compute the tree height.
Sample output with inputs: 0.4 17.5
1 Expert Answer

Patrick B. answered 11/03/20
Math and computer tutor/teacher
this is INCORRECT!!!!!
shadow length = 0.4
angle = 17.5
tan 17.5 = ? / 0.4
tan 17.5 * 0.4 = ?
0.31529878887898351767706493172587 * 0.4 = 0.12611951555159340707082597269035
is NOT 7.39+.....
In order for the tree to have that height, the correct formula is:
This means, tan 17.5 * shadow_length = 7.39888132...
so shadow length = 7.39888132.../tan17.5 = 23.466253562926416629793642378644
The formula you need is tree_length = tan(angle)*shadow_length
The following code uses that formula and the results are consistent with the calculations presented above in bold:
I have uploaded the source code (for this problem as well as the last one about the distance formula)
as well as a screen shot of the result which is consistent with these calculations.
I must upload them as text files with *.txt extension in order to upload them.
You will have to rename these files to python source code files with *.py extension.
Here is the code
# Online Python compiler (interpreter) to run Python online.
# Write Python 3 code in this online editor and run it.
import math
print("Hello world")
#inputs the shadow length and angle
shadow_length = input("Please input the shadow length :>")
angle = input(" Please input the angle in degrees :>")
#converts the angle to radians and calculates the tangent
radians = float(angle)*math.pi/float(180)
tTangent = math.tan(radians)
print(tTangent)
#calculates object height as tangent * shadow length
obj_height = tTangent*float(shadow_length)
#output
print('The height of the object is ' + str(obj_height))
Still looking for help? Get the right answer, fast.
Get a free answer to a quick problem.
Most questions answered within 4 hours.
OR
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.
Patrick B.
Source code and screen shot of CORRECT output have been uploaded to RESROUCES section under this link. You must rename the source code text file to python file with *.py extension11/03/20