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 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
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