Computing height given shadow length and angle of elevation

In summary, the program uses simple geometry and the formula tan(angleElevation) = treeHeight / shadowLength to compute the height of an object from its shadow length and angle. The program then outputs the tree height based on the given values for the shadow length and angle of elevation.
  • #1
needOfHelpCMath
72
0
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.
Code:
#include <iostream>
#include <cmath>
using namespace std;

int main( ) {
   double treeHeight     = 0.0;
   double shadowLength   = 0.0;
   double angleElevation = 0.0;

   angleElevation = 0.11693706; // 0.11693706 radians = 6.7 degrees
   shadowLength   = 17.5;

   
  treeHeight = cos(shadowLength) / angleElevation ;

   
   cout << "Tree height: " << treeHeight << endl;

   return 0;
}

My outputs

✖ Testing with shadowLength = 17.5, angleElevation = 0.11693706
Expected value: 2.05578
Your value: 1.87656
Tests aborted.
 
Technology news on Phys.org
  • #2
Re: What heck i am doing wrong?

treeHeight = shadowLength * tan(angleElevation)
 
  • #3
Please use thread titles that describe the posted problem...a title like "What the heck am I doing wrong?" doesn't tell people browsing the forums anything at all about what's being asked in the thread. :D

Not only will this increase the chances that you will get responses, but it improves the organization of our site and SEO as well. Everyone wins!
 

1. How do you calculate the height using shadow length and angle of elevation?

To calculate the height, you can use the formula: height = shadow length x tan(angle of elevation). This formula uses trigonometry to determine the height.

2. What is the angle of elevation and how do you measure it?

The angle of elevation is the angle between the horizontal (ground) and the line of sight to an object above. It can be measured using a protractor or a clinometer.

3. Can you calculate the height if the shadow length and angle of elevation are unknown?

No, the height cannot be calculated without at least one known variable. You need either the shadow length or the angle of elevation in order to use the formula and determine the height.

4. Is the height calculated using this method always accurate?

The calculated height may not be completely accurate due to potential errors in measuring the shadow length or angle of elevation. However, it can provide a close estimate of the actual height.

5. Can this method be used to calculate the height of any object?

Yes, this method can be used to calculate the height of any object as long as you have the necessary measurements and the object is within a reasonable distance.

Similar threads

  • Programming and Computer Science
Replies
2
Views
12K
Replies
4
Views
761
  • Programming and Computer Science
Replies
23
Views
1K
  • Programming and Computer Science
Replies
5
Views
2K
  • Programming and Computer Science
Replies
2
Views
3K
  • Programming and Computer Science
2
Replies
35
Views
2K
  • Programming and Computer Science
Replies
1
Views
1K
  • Programming and Computer Science
2
Replies
36
Views
2K
  • Programming and Computer Science
Replies
3
Views
9K
  • Programming and Computer Science
Replies
1
Views
2K
Back
Top