MHB Computing height given shadow length and angle of elevation

AI Thread Summary
The discussion focuses on calculating the height of an object, specifically a tree, using the length of its shadow and the angle of elevation. The correct formula for this calculation is tan(angleElevation) = treeHeight / shadowLength. A user attempted to implement this in C++ but encountered an error in their output, which did not match the expected value. The user incorrectly used the cosine function instead of the tangent function in their calculation. A suggestion was made to improve the thread title for better clarity and SEO, emphasizing the importance of descriptive titles for enhancing forum organization and response rates.
needOfHelpCMath
Messages
70
Reaction score
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
Re: What heck i am doing wrong?

treeHeight = shadowLength * tan(angleElevation)
 
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!
 
Thread 'Star maps using Blender'
Blender just recently dropped a new version, 4.5(with 5.0 on the horizon), and within it was a new feature for which I immediately thought of a use for. The new feature was a .csv importer for Geometry nodes. Geometry nodes are a method of modelling that uses a node tree to create 3D models which offers more flexibility than straight modeling does. The .csv importer node allows you to bring in a .csv file and use the data in it to control aspects of your model. So for example, if you...
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...

Similar threads

Replies
4
Views
1K
Replies
1
Views
2K
Replies
12
Views
3K
Replies
1
Views
2K
Replies
1
Views
2K
Replies
23
Views
3K
Back
Top