Advertisement

Square-Based Pyramid Volume

Started by February 20, 2003 08:31 AM
11 comments, last by Lektrix 22 years ago
For my G.C.S.E. coursework, I have decided to try and find the largest possible (within reason) volume of certain shapes when made of a net with an area of 100 cm². The size of the shape is dependent the size of an angle on the net. I have done a few and developed a base class and some subtypes for the shapes I have done. I am stuck on square-based pyramids though. I have some working formulae, yet given some sizes of degrees it does not work (I shall come onto this in a minute). Here is a quick image of what the net of my square-based pyramid looks like (please excuse, I am terrible at creating images ). net.gif. A is the size of the angle which is changed to try and find the largest volume possible. 25 cm² is the area of each of the net triangles (100 / 4 = 25). The problem that I have is that I need the pyramid's slant height, in order to use pythag to work the pyramid's height out. When one folds out the pyramid to form the net, the net triangles' heights are the pyramid's slant heights. Please look at the following image of one net triangle: net_triangle.gif. l = net triangle's height & pyramid's slant height x = half of the net triangle's base A = size of angle Area of net triangle = 25 cm² I figured that I could work out l by rearranging the formula for finding the area of a triangle (half base * height = area): x * l / 2 = 12.5 (12.5 is half of the net triangle's area). But there would be an unknown left in the formula, x. I used trig to find the formula for finding the value of x and substituted it in place of x in the formula for calculating the area of the net triangle: *gets breath back* tan = opp / adj tan(½A) = x / l x = tan(½A) * l x * l / 2 = 12.5 => tan(½A) * l * l / 2 = 12.5 Now I can rearrange the formula, making l to subject: tan(½A) * l² / 2 = 12.5 tan(½A) * l² = 25 l² = 25 / tan(½A) l = sqrt(25 / tan(½A)) This is ok for some values of A, but if the tan of half of A is a negative number it makes the whole formula not work: 25 divided by a negative number will result in a negative number and there is no such thing as a square root of a negative number. So, how can I get over this? I know this is a school project, so I am not saying that you should explicitly state what to do, yet some help would be nice. Someone mentioned maybe complex numbers for the square root of a negative number? Anyway, thanks in advance. Edit: Messed up URLs :0 [ Google || Start Here || ACCU || MSDN || STL || GameCoding || BarrysWorld || E-Mail Me ] [edited by - Lektrix on February 20, 2003 9:37:19 AM]
[ Google || Start Here || ACCU || STL || Boost || MSDN || GotW || CUJ || MSVC++ Library Fixes || BarrysWorld || [email=lektrix@barrysworld.com]E-Mail Me[/email] ]
The first thing to note is that if the four triangles have an area of 25cm2 then when you add the area of the base square you''ll have a net with gretaer area than 100cm2.
Advertisement
just a quick hint: if 0 < (A/2) < 90 degrees then tan(A/2) >0. As long as A/2 never goes out of these bounds you dont have the negative square root problem
quote:
Original post by Keem
The first thing to note is that if the four triangles have an area of 25cm2 then when you add the area of the base square you'll have a net with gretaer area than 100cm2.

Silly me, I meant to say that the surface area had to be 100 cm², which I believe, for a pyramid, is the area of the four triangles but not the area of the base.

quote:
Original post by Keem
just a quick hint: if 0 < (A/2) < 90 degrees then tan(A/2) >0. As long as A/2 never goes out of these bounds you dont have the negative square root problem

Hmmm, I am keeping within these boundaries. :/

Thanks for your help though; maybe I'm just making a silly mistake or maybe I'm not using tan right :/

[ Google || Start Here || ACCU || MSDN || STL || GameCoding || BarrysWorld || E-Mail Me ]

[edited by - Lektrix on February 20, 2003 12:08:45 PM]
[ Google || Start Here || ACCU || STL || Boost || MSDN || GotW || CUJ || MSVC++ Library Fixes || BarrysWorld || [email=lektrix@barrysworld.com]E-Mail Me[/email] ]
On my calculator, tan(1) = 0.017455064, whilst in Excel or "cmath", tan(1) = 1.55741. Am I doing something wrong? In both Excel and C++ I am calling tan() like: tan(17).

Here are the results from looping through and printing the tan of 1 to 89:

  #include "Console.h" #include <cmath> int main(){	Console outFile("results.txt"); 	for (int ix = 1; ix < 90; ++ix)		outFile << "tan("  << ix << ") = "		        << tan(ix) << ''\n''; 	return 0;} Contents of results.txt:tan(1) = 1.55741tan(2) = -2.18504tan(3) = -0.142547tan(4) = 1.15782tan(5) = -3.38052tan(6) = -0.291006tan(7) = 0.871448tan(8) = -6.79971tan(9) = -0.452316tan(10) = 0.648361tan(11) = -225.951tan(12) = -0.63586tan(13) = 0.463021tan(14) = 7.24461tan(15) = -0.855993tan(16) = 0.300632tan(17) = 3.49392tan(18) = -1.13731tan(19) = 0.151589tan(20) = 2.23716tan(21) = -1.5275tan(22) = 0.00885166tan(23) = 1.58815tan(24) = -2.1349tan(25) = -0.133526tan(26) = 1.17875tan(27) = -3.2737tan(28) = -0.28143tan(29) = 0.887143tan(30) = -6.40533tan(31) = -0.441696tan(32) = 0.661006tan(33) = -75.313tan(34) = -0.623499tan(35) = 0.473815tan(36) = 7.75047tan(37) = -0.840771tan(38) = 0.31031tan(39) = 3.61455tan(40) = -1.11721tan(41) = 0.160657tan(42) = 2.29139tan(43) = -1.49839tan(44) = 0.0177047tan(45) = 1.61978tan(46) = -2.08661tan(47) = -0.124528tan(48) = 1.20013tan(49) = -3.17291tan(50) = -0.271901tan(51) = 0.903086tan(52) = -6.05327tan(53) = -0.431158tan(54) = 0.6738tan(55) = -45.1831tan(56) = -0.611274tan(57) = 0.484699tan(58) = 8.33086tan(59) = -0.825774tan(60) = 0.32004tan(61) = 3.74317tan(62) = -1.09751tan(63) = 0.16975tan(64) = 2.34786tan(65) = -1.47004tan(66) = 0.0265605tan(67) = 1.65232tan(68) = -2.04008tan(69) = -0.115549tan(70) = 1.22196tan(71) = -3.07762tan(72) = -0.262417tan(73) = 0.919286tan(74) = -5.73702tan(75) = -0.420701tan(76) = 0.686748tan(77) = -32.2686tan(78) = -0.59918tan(79) = 0.495678tan(80) = 9.00365tan(81) = -0.810994tan(82) = 0.329826tan(83) = 3.8806tan(84) = -1.07818tan(85) = 0.17887tan(86) = 2.40673tan(87) = -1.44242tan(88) = 0.0354205tan(89) = 1.68583  

I get different values on my calculator.

[ Google || Start Here || ACCU || MSDN || STL || GameCoding || BarrysWorld || E-Mail Me ]
[ Google || Start Here || ACCU || STL || Boost || MSDN || GotW || CUJ || MSVC++ Library Fixes || BarrysWorld || [email=lektrix@barrysworld.com]E-Mail Me[/email] ]
Lektrix,

First let me say that you have posted a wonderful homework question. And by that I mean you followed my forum guidelines perfectly. You clearly want to understand what you''re doing! I appreciate this, ! Its a pleasure to try and help out.

That said, Keem already gave you the clue you need. Since (A/2) is between 0 and 90 degrees, you never have to fear that tan(A/2) will be negative. (Do note that A/2 cannot be 90 though since tan(90) is positive infinity). When A/2 is between 0 and 90, A itself can be between 0 and 180, which covers all "real" triangles.

Your equation for l is correct. I''m assuming you would plug that into your volume formula, in order to create a volume formula that is simply a function of A?

P.S. There is actually an area of math called "complex" math, which does indeed deal with the square root of negative numbers! This area of math defines the letter/symbol "i" to be equal to the square root of negative 1, i = sqrt(-1). Bizarre, eh?


Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.
Graham Rhodes Moderator, Math & Physics forum @ gamedev.net
Advertisement
from Letrix:
** tan = opp / adj
tan(½A) = x / l
x = tan(½A) * l ** <--- puzzled about this

tan(.5A) = x / l
x * (tan(.5A) = x * (x / l)
x * tan(.5A) = l
x = l / tan (.5A) <----- did i miss something in math class?

Beginner in Game Development?  Read here. And read here.

 

quote:
Original post by grhodes_at_work
Since (A/2) is between 0 and 90 degrees, you never have to fear that tan(A/2) will be negative.

This is what I originally thought, as I knew that the tan of 90 and -90 is infinite and minus infinite and I also know what a graphical representation of tan looks like, yet, as I mentioned in my third post, the tan() functions that I have been using are giving me different results than when I use my calculator. I'm pretty sure that the values that my computer is returning are wrong (well, not wrong, just not what I want). Can anyone help me? Am I doing something wrong?

quote:
Original post by grhodes_at_work
I'm assuming you would plug that into your volume formula, in order to create a volume formula that is simply a function of A?

Ay.

quote:
Original post by Alpha_ProgDes
did i miss something in math class?

Evidently yes. I'm pretty sure that what I did was correct.


tan = opp / adj

Therefore:
tan(½A) = x / l

Make x the subject:
Multiply both sides by l => x = tan(½A) * l


Thank you all that have posted so far!

[ Google || Start Here || ACCU || MSDN || STL || GameCoding || BarrysWorld || E-Mail Me ]

[edited by - Lektrix on February 20, 2003 2:25:35 PM]
[ Google || Start Here || ACCU || STL || Boost || MSDN || GotW || CUJ || MSVC++ Library Fixes || BarrysWorld || [email=lektrix@barrysworld.com]E-Mail Me[/email] ]

hee hee. you''re right.
carry on.
and good luck with your project!

Beginner in Game Development?  Read here. And read here.

 

Evidently excel shows tan() in radians, while your calculator is set to show tan() in degrees.

This topic is closed to new replies.

Advertisement