Compound miter brainteaser

Page 2 of 3  


Ok, here it is, check it. "woodlib.pl" just sets $in{} from the CGI variables.
#!/usr/bin/perl # -*- perl -*-
use POSIX;
$pi = atan2(1,1) * 4;
$original_email = '
Subject: Re: Best CAD Program for Woodworkers Newsgroups: rec.woodworking Date: Fri, 31 Oct 2003 13:51:59 GMT
Now to try and make the formula easier to understand we need to define two variables. The number of sides will be in variable "s". The angle of the sides, which we just calculated will be in variable "b" Just plug the correct values in this short formula and you will have your answer
a60/s x=arctan((cos b)*tan(a/2)) y=arcsin((sin b)*sin(a/2))
The "x" value will be the angle that you set your cross cut to.
The "y" value will be the angle that you set your saw blade to.
';
require "./woodlib.pl";
$sides = $in; $angle = $in;
$sides = 4 unless $sides > 0; $angle = 0 unless $angle > 0;
if ($angle =~ m@([0-9\.]+)/([0-9\.]+)@) { ($rise, $run) = ($1, $2); $angle = atan2($rise, $run); } else { $angle = $angle * $pi / 180; }
$a = $pi / $sides;
$x = atan(cos($angle)*tan($a)); $y = asin(sin($angle)*sin($a));
print "Content-type: text/html\n\n"; print `header Compound Cut Calculations`;
print "<center><table>";
&row("Number of sides:", $sides); &row("Angle of sides:", $angle * 180/$pi); &row("<br>", ""); &row("Cross Cut Angle:", $x * 180/$pi); &row("Blade Angle:", $y * 180/$pi);
sub row { $v = $_[1]; if ($v =~ m@[0-9]\.@) {     $v = sprintf("%.1f", $v); } print "<tr><td align=right nowrap>$_[0] </td><td align=right><tt>&nbsp; $v</tt></td></tr>\n"; }
print "</table></p>";
print "<p><a href=\"compound-cuts.html\">Return to the Form</a></p>\n";
print "</center>";
print `trailer`;
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
DJ Delorie wrote:

s/b $a/2:
$x = atan(cos($angle)*tan($a/2)); $y = asin(sin($angle)*sin($a/2));
Though, I didn't verify on your page.
er
--
email not valid

Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

$a is already halved. It's computed as $pi / $sides, not 2*$pi / sides.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
DJ Delorie wrote:

Right you are. It was my definition of Asin. :(
er
--
email not valid

Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

And mine was no formulas--just visualize and figure it out, with lots of chances for errors.But sounds like we are all agreed on the miter, and just need to settle on the bevel.
--
Alex -- Replace "nospam" with "mail" to reply by email. Checked infrequently.

Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

Finally, I got 6.827. I found this pretty tricky to visualize. Glad some of you had formulas and programs, so I would know each time I got a wrong answer!
Josh, are these the answers you expected?
--
Alex -- Replace "nospam" with "mail" to reply by email. Checked infrequently.

Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
DJ Delorie wrote:

*Looks again*
Heh. The more I look at your web pages the more silly I feel having made that statement.
er
--
email not valid

Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
I agree with your algorithm, DJ. Several such algorithms can be found on the web, often for computing compound miters for crown molding, which is essentially the same problem. But many of them give slightly different answers. Why is yours right, and what's wrong with the other ones?
If you don't want to see a bunch of crazy math, stop reading now.
One of the other common algoriths for computing the miter (x in your notation) is x=1/2*arccos(cos^2(b)*cos(a)+sin^2(b)). This is a pretty simple equation to derive using simple vector algebra. Going back to first semester Calculus, recall that the dot product of two vectors is defined as a scalar value equal to the product of the vector magnitudes times the cosine of the angle between them.
A.dot.B = |A| * |B| * cos(alpha),
where alpha is the angle formed between them, and the | | notation means magnitude (i.e. length, independent of direction).
A second way to calculate the dot product is to write the vectors as functions of the unit vectors i, j, and k which are simply vectors of length 1 along the x, y, and z axes. If the vectors are written as A ax*i + ay*j + az*k and B = bx*i + by*j + bz*k then their dot product is simply
A.dot.B = ax*bx + ay*by + az*bz
Now if we simply find two vectors which form one wedge of the ten-sided roof, we can easily compute the angle between them by using the two definitions of dot product. It's an easy construction:
If we take the peak of the roof to be the point (0,0,0), and we imagine ten rafters radiating outward, angled down with a pitch (slope) of 5/12, then it's easy to find their endpoints (which will define our vectors). If we assume for simplicity's sake that they have a length of 1 foot, then one of the rafters would stretch from (0,0,0) to (cos(atan(5/12)),0,-sin(atan(5/12))). Since the choice of 5/12 for a pitch gives us a 5-12-13 right triangle, we can simpify the second coordinate of the vector to (12/13,0,-5/13). A second rafter would start at (0,0,0) and go to (12/13*cos(36), 12/13*sin(36), -5/13). The 36 degree angle is the angle of one wedge of roof when viewed from directly above (i.e. there are ten sides so the the angle is a tenth of 360).
Now that we have two vectors, we can compute their dot product both of the ways desribed above.
A.dot.B = |A| * |B| * cos (angle) = 1 * 1 * cos (alpha) = cos(alpha) A.dot.B = 12/13*12/13*cos(36) + 0*12/13*sin(36) + 5/13*5/13
Equating the two different definitions we get ((12/13)^2*cos(36) + (5/13)^2)= cos (alpha)
Thus alpha = arccos(0.83727) = 33.147 degrees.
This is the angle between the two vectors (i.e. the two roof rafters). The miter angle is simply going to be half of this angle, or
x = 16.57 degrees.
This is pretty close to what DJ's formula gives us, yet it's slightly different. Why?
I'll post the reason next. I don't want this one post to get too long.
Josh
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
somehow after atepting to try and understand
i declare myself (STUPID)

Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Even though the formula I referenced previously (which can be found as the basis for several compound miter calculators) is easily derived, there was an essential flaw in the construction of the problem (but not in the math, itself). The crux of the problem is that even though the roof pitch is 5/12, the pitch of the rafters is not 5/12 (at least not the ten main rafters which form the wedges which comprise the roof). If we added ten more secondary rafters to the roof frame ran down the middle of each wedge, bisecting the 36 degree angle, those would have a pitch of 5/12.
To put this in a way that is easier to picture, imagine that the secondary rafters are 13 feet long, thus forming a 5-12-13 triangle. The would have a rise of 5 feet, a horizontal run of 12 feet, and an overall length of 13 feet. To keep the eaves of the roof level, the main rafters would, of course, have to drop the same 5 feet total at their end points. However, they would have to be longer than 13 feet. They would in fact be 13/cos(18) feet long. Thus, their pitch would actually be less than 5/12, and that's why the other formula is wrong.
Josh
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Josh wrote:

Hah, that's gorgeous... 5/12 is the pitch along a line perpendicular to the direction of the slope, but the rafters are not that. :)
The other formula will work if you adjust your slope to
    slope = sqrt(rise^2/(rise^2+run^2))
won't it? (seems to, based on a test using my own proggie)
er
--
email not valid



Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Enoch Root (in dN-dnaZXkMA1r1HenZ2dnUVZ snipped-for-privacy@forethought.net) said:
| Hah, that's gorgeous... 5/12 is the pitch along a line | perpendicular to the direction of the slope, but the rafters are | not that. :) | | The other formula will work if you adjust your slope to | | slope = sqrt(rise^2/(rise^2+run^2)) | | won't it? (seems to, based on a test using my own proggie)
You're obviously having too much fun with this. Just to open things up a bit for all the people who don't have bc (but _do_ have a C compiler):
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h>
int main(void) { char input[128]; double sides,rise,run,slant,angle,miter,bevel;
printf("How many sides? "); fflush(stdout); fgets(input,80,stdin); sscanf(input,"%lf\n ",&sides); angle = 2 * M_PI / sides;
printf("What is the slant (degrees or rise/run)? "); fflush(stdout); fgets(input,80,stdin); if (strchr(input,'/')) { sscanf(input,"%lf/%lf",&rise,&run); slant = atan(rise / run); } else { sscanf(input,"%lf",&slant); slant = M_PI * slant / 180; }
miter = atan(cos(slant) * tan(angle / 2)); bevel = asin(sin(slant) * sin(angle / 2));
printf("\nThe miter is %0.2lf degrees\n", miter * 180 / M_PI); printf("The bevel is %0.2lf degrees\n" , bevel * 180 / M_PI);
return EXIT_SUCCESS; }
This program allows entering the "slant" in degrees or as rise/run (like 5/12). It's "quick and dirty" and does no error checking, but should be compilable with even TurboC version 1 (I used 3.0).
-- Morris Dovey DeSoto Solar DeSoto, Iowa USA http://www.iedu.com/DeSoto/solar.html
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

If you have neither bc nor a C compiler, my script uses the same math (and allows for rise/run too):
http://www.delorie.com/wood/compound-cuts.html
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
DJ Delorie (in snipped-for-privacy@delorie.com) said:
|| You're obviously having too much fun with this. Just to open things || up a bit for all the people who don't have bc (but _do_ have a C || compiler): | | If you have neither bc nor a C compiler, my script uses the same | math (and allows for rise/run too): | | http://www.delorie.com/wood/compound-cuts.html
Your script is much appreciated (but not as much your ABPW archive and nowhere near as much as your efforts to make a C compiler freely available to all) - but there are more than 15 miles between my shop and my internet access.
For those with a similar situation, the C source can be found in the collection at www.iedu.com/mrd/c/ as cbevel.c - sometimes it's a Good Thing to be able to function independently from the internet. :-)
-- Morris Dovey DeSoto Solar DeSoto, Iowa USA http://www.iedu.com/DeSoto /
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

Except for the corner ones, my rafters are. They have to run parallel to the seams in the plywood sheathing.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

Well, not to be picky, but... There is no flaw in the construction of the problem. The flaw is in the solution, using the roof slope as the slope of the diagonal rafters.

this part, getting the miter angle, is way easier than the dot product solution. Consider 1/2 of one of the roof wedges. Vertically, it is a 12/5/13 right triangle, so the length from the peak to the eve is 13. Horizontally, it is an 18 degree right triangle, with the long leg of 12. Trig tables give us the other leg as 3.9. So the half wedge forming the roof is a right triangle with legs of 13 and 3.9, from which we use trig to get a miter angle of 16.7.
It's the bevel angle that stumps me. I got an answer consistent with the one posted from the calculators, but without more digits of precision, I'm not very confident of mine. And unless one of you computer types want to "program" this solution in Excel <gasp!>, I'm not able to play around with the precision. My solution still causes brain strain when I try to reconstruct it! <g>
--
Alex -- Replace "nospam" with "mail" to reply by email. Checked infrequently.

Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

Never mind. I created a spreadsheet solution that duplicates the web page cited here, and in so doing got my brain round the bevel angle.
--
Alex -- Replace "nospam" with "mail" to reply by email. Checked infrequently.

Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

Wouldn't it be 18 degrees?
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
snipped-for-privacy@gmail.com says...

an interesting problem. it is solved by noting that the rafters, when viewed from above, look like an outside corner crown moulding (c.m.) problem.
the pitch of the rafters (5:12 = 22.6degrees) becomes the c.m. angle, while the inclusion angle becomes (180-36)/2 = 72degrees (again, since it's an outside corner crown moulding).
in this specific case the result is: miter = pi/2 - [atan (cos(22.6) / tan (72)] = 16.7deg bevel = atan [cot(pi/2 - 22.6) * sin(pi/2 - 16.7) ] = 6.8degrees
for those who want to visualize what's going on or who aren't necessarily good at trig, check out my tutorial at <<http://users.adelphia.net/~kimnach/woodworking/compoundangle.htm
-- regards, greg
http://users.adelphia.net/~kimnach
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Nice tutorial.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

Related Threads

    HomeOwnersHub.com is a website for homeowners and building and maintenance pros. It is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.