#!/usr/local/bin/perl # perl script for Offset Hips on Bay Window Rafter Calculations # type 4: referred to as Joe Carola Bay To Point Baywindow # "Warning this roof should only be attempted by master roof cutters and stackers". # type 1 WestBuild Baywindow # type 2 Joe Carola Baywindow # type 3 EastBuild Baywindow # type 4 Joe Carola Unequal Pitch Baywindow # type 5 Bay To Point Baywindow # type 6 Equal Pitch Baywindow use CGI::Carp qw(fatalsToBrowser); #comment out this line when your done debugging this script $|++; #dont't buffer output #use strict; # file name:: bay-to-point-baywindow.cgi # Created on Sunday, July 15, 2007 by Sim Ayers of SBE Builders # get latest version of this script at http://www.sbebuilders.com ################################################### # You are free to customize this script as you wish. # DISCLAIMER # The information and code provided is provided 'as is' without # warranty of any kind, either express or implied. In no event # shall the Company SBE Builders be liable for any damages whatsoever # including direct, indirect, incidental, consequential, loss of # business profits or special damages, even if the author has been # advised of the possibility of such damages. # DO NOT USE THIS SCRIPT UNLESS YOU CAN FULLY AGREE WITH THIS # DISCLAIMER. # copyright(C) 2007 ################################################### my ($content_type_printed,%data,$back_wall,$projection,$face_wall,$pitch,$show_feet_inches); # print out perl headers to browser print "Content-type: text/plain\n\n" unless $content_type_printed++; &read_input(); #read user input variables if ($data{'face_wall'} eq ""){ # hand edit baywindow variables below for default values $projection = 24; $face_wall = 72; $major_pitch = 8; $show_feet_inches = 'no'; $jack_spacing = 12; $overhang = 12; } else{ $projection = $data{'projection'}; $face_wall = $data{'face_wall'}; $major_pitch = $data{'major_pitch'}; $show_feet_inches = $data{'show_feet_inches'}; $jack_spacing = $data{'jack_spacing'}; $overhang = $data{'overhang'}; } # walls at 45 degree angles to face wall $projection_offset = $projection; #Global symbols # http://perldoc.perl.org/Math/Complex.html use Math::Complex qw(:trig); use POSIX qw(ceil floor); $PIE = 3.14159265358979323846; $RAD_TO_DEGREE = (180/pi); $DEGREE_TO_RAD = ($PIE/180); $RAD_TO_DEGREE45 = (0.785398163397448309616); $dxf_line_count = 100; $DXF_STYLE=0; #dxf Line style $DXF_LAYER=0; #dxf file LAYER number $DXF_COLOR=0; # dxf line color $DXF_TSIZE=4.0; #dxf default dxf text size $half_the_thickness_of_the_hips = 0.75; # get geometry angles for baywindow $projection_wall_angle_deg = 45; $projection_offset_wall_angle_deg = 90 - $projection_wall_angle_deg; $interior_wall_angle_deg = 135; $projection_wall_length = $projection_offset / cos($projection_wall_angle_deg * $DEGREE_TO_RAD); $half_projection_wall_length = $projection_wall_length / 2; $face_wall_half = $face_wall /2; # the overhang is the same run at each side of the baywindow, so we can find the fascia points using 67.5° angles $bay_hip_rafter_offset_at_fascia = $overhang / tan(67.5 * $DEGREE_TO_RAD); # fascia_face_wall_half is the end point of the fascia from the center of the baywindow $fascia_face_wall_half = $bay_hip_rafter_offset_at_fascia + $face_wall_half; # the over hang rise is first calculated from the side wall common rafters, which are running at a 45° to the fascia line $diagonal_overhang = hypot($overhang,$overhang); # calculate total span for Baywindow # span = side wall projection * 2 + face wall length $span = ($projection * 2) + $face_wall; $major_common_rafter_run = $span / 2; # $major_common_rafter_run_to_fascia and $common_rafter_rise_from_fascia are the two dimensions that determind the face wall pitch $major_common_rafter_run_to_fascia = ($major_common_rafter_run + $diagonal_overhang); $common_rafter_rise = $major_common_rafter_run * ($major_pitch / 12); $common_rafter_rise_from_fascia = ($major_common_rafter_run + $diagonal_overhang) * ($major_pitch / 12); $minor_common_rafter_run = $projection; $minor_common_rafter_run_to_fascia = ($minor_common_rafter_run + $overhang); $minor_common_rafter_run_from_fascia = $projection + $overhang; $minor_pitch_angle = $RAD_TO_DEGREE * atan($common_rafter_rise_from_fascia / $minor_common_rafter_run_from_fascia); $minor_pitch = (tan($minor_pitch_angle * $DEGREE_TO_RAD) ) * 12; # double check face wall rise to see if it matchs the side common rise $minor_common_rafter_rise = $minor_common_rafter_run * ($minor_pitch / 12); $minor_common_rafter_rise_from_fascia = ($minor_common_rafter_run + $overhang) * ($minor_pitch / 12); # calculate hip offsets from fascia overhang for unequal pitch Baywindow $bay_hip_rafter_run_bisect_angle_deg = $RAD_TO_DEGREE * atan($minor_common_rafter_run_to_fascia / ($face_wall_half + $bay_hip_rafter_offset_at_fascia)); $bay_hip_rafter_top_angle_deg = 90 - $bay_hip_rafter_run_bisect_angle_deg; $bay_hip_rafter_run_to_fascia = $minor_common_rafter_run_to_fascia / sin($bay_hip_rafter_run_bisect_angle_deg * $DEGREE_TO_RAD); $overhang_bay_hip_run = $overhang / cos($bay_hip_rafter_top_angle_deg * $DEGREE_TO_RAD); $bay_hip_rafter_run = $bay_hip_rafter_run_to_fascia - $overhang_bay_hip_run; $bay_hip_rafter_offset_at_face_wall_corner = $face_wall_half - ($minor_common_rafter_run/ tan($bay_hip_rafter_run_bisect_angle_deg * $DEGREE_TO_RAD)); $bay_hip_rafter_run_bisect_adj_angle_deg = 135 - $bay_hip_rafter_run_bisect_angle_deg; $bay_hip_rafter_run_bisect_adj_top_angle_deg = 90 - $bay_hip_rafter_run_bisect_adj_angle_deg; $major_pitch = $major_pitch; $pitch_angle = $RAD_TO_DEGREE * atan($major_pitch / 12); $Major_Pitch = atan($major_pitch / 12); $Minor_Pitch = atan($minor_pitch / 12); $common_rafter_length = $major_common_rafter_run / cos(atan($major_pitch / 12)); $common_rafter_length_to_fascia = $major_common_rafter_run_to_fascia / cos(atan($major_pitch / 12)); $common_jackrafter_run = $jack_spacing * tan(45 * $DEGREE_TO_RAD); $common_jackrafter_length = $common_jackrafter_run / cos(atan($major_pitch / 12)); $zero_tail = $overhang / cos(45 * $DEGREE_TO_RAD); $overhang_major = $zero_tail / cos(atan($major_pitch / 12)); $minor_common_rafter_length = $minor_common_rafter_run / cos(atan($minor_pitch / 12)); $minor_common_jackrafter_run = $jack_spacing * tan($bay_hip_rafter_run_bisect_angle_deg * $DEGREE_TO_RAD); $minor_common_jackrafter_length = $minor_common_jackrafter_run / cos(atan($minor_pitch / 12)); $minor_overhang_face_wall_length = $overhang / cos(atan($minor_pitch / 12)); $bay_hip_rafter_angle = atan($common_rafter_rise_from_fascia / $bay_hip_rafter_run_to_fascia); $bay_hip_rafter_length = $bay_hip_rafter_run / cos($bay_hip_rafter_angle); $bay_hip_rafter_bevel_angle = 90 - $bay_hip_rafter_run_bisect_angle_deg; $bay_hip_rafter_unit_run = (12 / sin($DEGREE_TO_RAD * $bay_hip_rafter_run_bisect_angle_deg)); $bay_hip_rafter_pitch = (tan($bay_hip_rafter_angle) ) * 12; $overhang_bay_hip_length = $overhang_bay_hip_run / cos($bay_hip_rafter_angle); $bay_hip_rafter_length_to_fascia = $bay_hip_rafter_run_to_fascia / cos($bay_hip_rafter_angle); # calculate the rafter angle for 45 wall rafters # since the side wall is running at 45 degrees, then find the rise for the major pitch using the hypot of 24'' triangle $a_run = hypot(24,24); $a_rise = tan($Major_Pitch) * $a_run; $wall_common_rafter_angle = atan($a_rise/ 24); $wall_common_rafter_run_to_fascia = $bay_hip_rafter_run_to_fascia * sin($bay_hip_rafter_run_bisect_adj_angle_deg * $DEGREE_TO_RAD); $wall_common_rafter_run = $wall_common_rafter_run_to_fascia - $overhang; $wall_common_rafter_pitch = (tan($wall_common_rafter_angle) ) * 12; $Minor_Pitch = $wall_common_rafter_angle; $wall_common_rafter_length = $wall_common_rafter_run / cos($wall_common_rafter_angle); $wall_common_rafter_length_to_fascia = $wall_common_rafter_run_to_fascia / cos($wall_common_rafter_angle); $wall_common_jackrafter_run = $jack_spacing * tan(45 * $DEGREE_TO_RAD); $wall_common_jackrafter_length = $wall_common_jackrafter_run / cos($wall_common_rafter_angle); # find the king_projection_wall_length, which is a right triangle with the back bay hip run # this will give us the theoretical location for the 45 wall king common, which can be located off the 45 $hip_offset = $bay_hip_rafter_offset_at_face_wall_corner * (sin($bay_hip_rafter_run_bisect_angle_deg * $DEGREE_TO_RAD) / sin((135 - $bay_hip_rafter_run_bisect_angle_deg) * $DEGREE_TO_RAD)) ; $line_offset = $wall_common_rafter_run * tan($bay_hip_rafter_run_bisect_adj_top_angle_deg * $DEGREE_TO_RAD); $king_offset = $line_offset - $hip_offset; # orginal code $king_projection_wall_length = $projection_wall_length - $king_offset; $king_projection_wall_length = $major_common_rafter_run * cos(45 * $DEGREE_TO_RAD); $overhang_run_45_wall = $overhang; # $overhang_bay_hip_run * cos($bay_hip_rafter_run_bisect_adj_top_angle_deg * $DEGREE_TO_RAD); $overhang_45_wall_length = $overhang_run_45_wall / cos($wall_common_rafter_angle); $major_overhang_rise = hypot($overhang,$overhang) * ($major_pitch / 12); $minor_overhang_rise = $overhang * ($minor_pitch / 12); $rise_45_wall = $overhang * tan($wall_common_rafter_angle); $wall_common_rafter_HAP = $rise_45_wall - $major_overhang_rise; $minor_common_rafter_HAP = $minor_overhang_rise - $major_overhang_rise; print "Offset Hips on Bay Window Rafter Calculations\nType 5: Bay To Point Baywindow"; print "\nCalculations are rounded to the nearest 1/16 inch"; print "\n\n Face Wall length = " .convertTOfeet($face_wall); print "\n\n Projection of Bay Window = " .convertTOfeet($projection); print "\n\n Projection Offset = " .convertTOfeet($projection_offset); print "\n\n Projection Wall Length = " .convertTOfeet($projection_wall_length); print "\n\n Projection Wall Angle = " .roundAngle($projection_wall_angle_deg); print "\n\n Projection Offset Wall Angle = " .roundAngle($projection_offset_wall_angle_deg); print "\n\n Interior Wall Angle = " .roundAngle($interior_wall_angle_deg); print "\n\n\n Bay Hip Rafter Run Bisect Angle = " .roundAngle($bay_hip_rafter_run_bisect_angle_deg); print "\n\n Bay Hip Rafter Run Top Bisect Angle = " .roundAngle($bay_hip_rafter_top_angle_deg); print "\n\n Bay Hip Rafter Run Adjacent Bisect Angle = " .roundAngle($bay_hip_rafter_run_bisect_adj_angle_deg); print "\n\n Bay Hip Rafter Run Top Adjacent Bisect Angle = " .roundAngle($bay_hip_rafter_run_bisect_adj_top_angle_deg); print "\n\n\n Major Common Rafter Run = " .convertTOfeet($major_common_rafter_run); print "\n\n Major Common Rafter Run To Fascia = " .convertTOfeet($major_common_rafter_run_to_fascia); print "\n\n Major Common Rafter Pitch = " .roundAngle($major_pitch); print "\n\n Major Common Rafter Pitch Angle = " .roundAngle($pitch_angle); print "\n\n Major Common Rafter Rise = " .convertTOfeet($common_rafter_rise); print "\n\n Major Common Rafter Rise From Fascia = " .convertTOfeet($common_rafter_rise_from_fascia); print "\n\n Major Common Rafter Length = " .convertTOfeet($common_rafter_length); print "\n\n Major Common Rafter Length To Fascia = " .convertTOfeet($common_rafter_length_to_fascia); print "\n\n Major Common Rafter Overhang Run = " .convertTOfeet($overhang); print "\n\n Major Common Rafter Overhang Diagonal Run = " .convertTOfeet($diagonal_overhang); print "\n\n Major Common Overhang Diagonal Rafter Length At 45 Wall = " .convertTOfeet($overhang_major); print "\n\n\n Minor Common Rafter Run = " .convertTOfeet($minor_common_rafter_run); print "\n\n Minor Common Rafter Run To Fascia = " .convertTOfeet($minor_common_rafter_run_to_fascia); print "\n\n Minor Common Rafter Pitch = " .roundAngle($minor_pitch); print "\n\n Minor Common Rafter Pitch Angle = " .roundAngle($minor_pitch_angle); print "\n\n Minor Common Rafter Rise = " .convertTOfeet($minor_common_rafter_rise); print "\n\n Minor Common Rafter Rise From Fascia = " .convertTOfeet($minor_common_rafter_rise_from_fascia); print "\n\n Minor Common Rafter Length = " .convertTOfeet($minor_common_rafter_length); print "\n\n Minor Common Rafter Overhang Run = " .convertTOfeet($overhang); print "\n\n Minor Common Overhang Rafter Length = " .convertTOfeet($minor_overhang_face_wall_length); print "\n\n Minor Common Jack Rafter Spacing = " .convertTOfeet($jack_spacing); print "\n\n Minor Common Jack Rafter Difference in Length = " .convertTOfeet($minor_common_jackrafter_length); print "\n\n Minor Common Rafter H.A.P Adjustment = " .convertTOfeet($minor_common_rafter_HAP); print "\n\n\n Bay Hip Rafter Angle = " .roundAngle($bay_hip_rafter_angle * $RAD_TO_DEGREE); print "\n\n Bay Hip Rafter Pitch = " .convertTOpitch($bay_hip_rafter_pitch) ." /12"; print "\n\n Bay Hip Rafter Bevel Angle = " .roundAngle($bay_hip_rafter_bevel_angle); print "\n\n Bay Hip Rafter Run = " .convertTOfeet($bay_hip_rafter_run); print "\n\n Bay Hip Rafter Length = " .convertTOfeet($bay_hip_rafter_length); print "\n\n Bay Hip Rafter Run To Fascia = " .convertTOfeet($bay_hip_rafter_run_to_fascia ); print "\n\n Bay Hip Rafter Length To Fascia = " .convertTOfeet($bay_hip_rafter_length_to_fascia ); print "\n\n Bay Hip Rafter Overhang Run = " .convertTOfeet($overhang_bay_hip_run); print "\n\n Bay Hip Rafter Overhang Rafter Length = " .convertTOfeet($overhang_bay_hip_length); print "\n\n Bay Hip Rafter Offset At Fascia = " .convertTOfeet($bay_hip_rafter_offset_at_fascia); print "\n\n Bay Hip Rafter Offset At Face Wall Corner = " .convertTOfeet($bay_hip_rafter_offset_at_face_wall_corner); print "\n\n\n 45 Wall Common Rafter Angle = " .roundAngle($wall_common_rafter_angle * $RAD_TO_DEGREE); print "\n\n 45 Wall Rafter Pitch = " .convertTOpitch($wall_common_rafter_pitch) ." /12"; print "\n\n 45 Wall King Common Rafter Run = " .convertTOfeet($wall_common_rafter_run); print "\n\n 45 Wall King Common Rafter Length = " .convertTOfeet($wall_common_rafter_length); print "\n\n 45 Wall King Common Rafter Run To Fascia = " .convertTOfeet($wall_common_rafter_run_to_fascia); print "\n\n 45 Wall King Common Rafter Length To Fascia = " .convertTOfeet($wall_common_rafter_length_to_fascia); print "\n\n 45 Wall King Common Rafter Offset From Corner = " .convertTOfeet($king_offset); print "\n\n 45 Wall Jack Rafter Spacing = " .convertTOfeet($jack_spacing); if($king_offset > $jack_spacing){ print "\n\n 45 Front Back Jack Rafter Difference in Length = " .convertTOfeet($wall_common_jackrafter_length); } if($wall_common_jackrafter_length < $wall_common_rafter_length){ print "\n\n 45 Wall Back Jack Rafter Difference in Length = " .convertTOfeet($wall_common_jackrafter_length); } print "\n\n 45 Wall Common Rafter Overhang Run = " .convertTOfeet($overhang_run_45_wall); print "\n\n 45 Wall Common Rafter Overhang Rafter Length = " .convertTOfeet($overhang_45_wall_length); print "\n\n 45 Wall Common Rafter H.A.P Adjustment = " .convertTOfeet($wall_common_rafter_HAP); =head http://ca.geocities.com/xpf51/HVFRAMING/framing_angles_vector.html Framing Angle Calculator http://ca.geocities.com/web_sketches/framing_math_notes/plan_angle_formula/plan_angle_geometry.html Major Plan Angle Calculation =cut #Major Plan Angle Calculation $Eave_Angle = 135 * $DEGREE_TO_RAD; $Major_Pitch_Angle = $wall_common_rafter_angle; $Minor_Pitch_Angle = $minor_pitch_angle * $DEGREE_TO_RAD; $sin_Eave_Angle = sin ($Eave_Angle); $cos_Eave_Angle = cos ($Eave_Angle); $MajorPitch_divide_by_MinorPitch = $Major_Pitch_Angle / $Minor_Pitch_Angle; $MinorPitch_divide_by_MajorPitch = $Minor_Pitch_Angle / $Major_Pitch_Angle; $tan_Major_Plan_Angle = ($sin_Eave_Angle / ($MajorPitch_divide_by_MinorPitch + $cos_Eave_Angle)); $tan_Minor_Plan_Angle = ($sin_Eave_Angle / ($MinorPitch_divide_by_MajorPitch + $cos_Eave_Angle)); $Major_Plan_Angle_RAD = atan($tan_Major_Plan_Angle); $Minor_Plan_Angle_RAD = atan($tan_Minor_Plan_Angle); $Frieze_Block_Angle = atan (sin ($Major_Pitch_Angle) / tan($Major_Plan_Angle_RAD)); $Frieze_Block_Bevel_Angle = atan (sin ($Frieze_Block_Angle) / tan ($Major_Pitch_Angle)); print "\n\n\n Bay Hip Plan Angle = " .roundAngle($Major_Plan_Angle_RAD * $RAD_TO_DEGREE); print "\n\n Face Wall Frieze Block Angle = " .roundAngle($Frieze_Block_Angle * $RAD_TO_DEGREE); print "\n\n Face Wall Frieze Block Bevel Angle = " .roundAngle($Frieze_Block_Bevel_Angle * $RAD_TO_DEGREE); #Backing Angle = arctan (sin Hip Pitch Angle ÷ tan Plan Angle) $Backing_Angle = atan (sin($bay_hip_rafter_angle) / $tan_Minor_Plan_Angle); print "\n\n\nBay Hip Rafter Backing Angle On Face Wall= " .roundAngle($Backing_Angle * $RAD_TO_DEGREE); $Backing_Angle = atan (sin($bay_hip_rafter_angle * $DEGREE_TO_RAD) / $tan_Major_Plan_Angle); print "\n\nBay Hip Rafter Backing Angle On 45° Wall= " .roundAngle($Backing_Angle * $RAD_TO_DEGREE); $Backing_Angle = atan (sin($pitch_angle * $DEGREE_TO_RAD) / tan (45 * $DEGREE_TO_RAD)); print "\n\nBacking Angle Of Rafter Against Wall= " .roundAngle($Backing_Angle * $RAD_TO_DEGREE); print "\n\n\n"; $bay_hip_rafter_drop = ($minor_pitch * ($half_the_thickness_of_the_hips / tan($bay_hip_rafter_run_bisect_angle_deg * $DEGREE_TO_RAD))/$bay_hip_rafter_unit_run); print "\n\n Bay Hip Rafter Drop = " .convertTOfeet($bay_hip_rafter_drop); print "\n\n\nJoe Bartok's Irregular Roof Framing Plan Angle Formulas Check"; print "\n\n\nhttp://ca.geocities.com/web_sketches/framing_math_notes/plan_angle_formula/plan_angle_geometry.html"; print "\n\nEave_Angle = " .roundAngle_5($Eave_Angle * $RAD_TO_DEGREE); print "\n\nMajor_Pitch_Angle = " .roundAngle_5($Major_Pitch_Angle); print "\n\nMinor Pitch Angle = " .roundAngle_5($Minor_Pitch_Angle); print "\n\nsin Eave_Angle = " .roundAngle_5($sin_Eave_Angle); print "\n\ncos Eave_Angle = " .roundAngle_5($cos_Eave_Angle); print "\n\nMajorPitch_divide_by_MinorPitch = " .roundAngle_5($MajorPitch_divide_by_MinorPitch); print "\n\ntan_Major_Plan_Angle = " .roundAngle_5($tan_Major_Plan_Angle); print "\n\nMajor_Plan_Angle = " .roundAngle_5($Major_Plan_Angle_RAD * $RAD_TO_DEGREE); print "\n\nMinor_Plan_Angle = " .roundAngle_5($Minor_Plan_Angle_RAD * $RAD_TO_DEGREE); print "\n\n\n"; # text file with dxf header information $DXF_HEADER_FILE = "dxf_header.txt"; # text file to save dxf drawing to $DXF_File="bay-to-point-baywindow.dxf"; #load dxf header file $dxf_header = get_dxf_header_file($DXF_HEADER_FILE); open(FILE, ">$DXF_File") || die("$DXF_File: Can't open because ($!)."); # add dxf header information to dxf output file print FILE "$dxf_header\n0\n"; # origin of left top side of baywindow in dxf document $originX = 25; $originY = 100; #$offset = $overhang * tan($bay_hip_rafter_top_angle_deg * $DEGREE_TO_RAD); # keep the overhang the same run at each wall $offset = $overhang * tan(22.5 * $DEGREE_TO_RAD); $offset_45 = $overhang * tan($bay_hip_rafter_run_bisect_adj_top_angle_deg * $DEGREE_TO_RAD); $offset_fascia = $overhang / cos(45 * $DEGREE_TO_RAD); $offset_zero_fascia = $overhang * cos(45 * $DEGREE_TO_RAD); # draw left 45 wall $x1 = $originX; $y1 = $originY; $x2 = $originX + $projection; $y2 = $originY - $projection; dxf_line($x1,$y1,$x2,$y2); # draw face wall $x1 = $originX + $projection; $y1 = $originY - $projection; $x2 = $originX + $projection + $face_wall; $y2 = $originY - $projection; dxf_line($x1,$y1,$x2,$y2); # draw right 45 wall right $x1 = $originX + $projection + $face_wall; $y1 = $originY - $projection; $x2 = $originX + $projection + $face_wall + $projection; $y2 = $originY; dxf_line($x1,$y1,$x2,$y2); # draw back wall $x1 = $originX; $y1 = $originY; $x2 = $originX + $projection + $face_wall + $projection; $y2 = $originY; dxf_line($x1,$y1,$x2,$y2); # draw back wall left rafter $x1 = $originX + $major_common_rafter_run; $y1 = $originY; $x2 = $originX - $offset_fascia; $y2 = $originY; dxf_line($x1,$y1,$x2,$y2); # draw back wall right rafter $x1 = $originX + $major_common_rafter_run; $y1 = $originY; $x2 = $originX + $projection + $face_wall + $projection + $offset_fascia; $y2 = $originY; dxf_line($x1,$y1,$x2,$y2); # draw left face wall bay hip run to fascia $x1 = $originX + $projection - $offset; $y1 = $originY - $projection - $overhang; $x2 = $originX + $major_common_rafter_run; $y2 = $originY - $projection - $overhang + $minor_common_rafter_run_to_fascia; dxf_line($x1,$y1,$x2,$y2); # draw right face wall bay hip run to fascia $x1 = $originX + $projection + $face_wall + $offset; $y1 = $originY - $projection - $overhang; $x2 = $originX + $major_common_rafter_run; $y2 = $originY - $projection - $overhang + $minor_common_rafter_run_to_fascia; dxf_line($x1,$y1,$x2,$y2); # draw face wall fascia line $x1 = $originX + $projection - $offset; $y1 = $originY - $projection - $overhang; $x2 = $originX + $projection + $face_wall + $offset; $y2 = $originY - $projection - $overhang; dxf_line($x1,$y1,$x2,$y2); # draw left fascia line at 45 wall $x1 = $originX + $projection - $offset; $y1 = $originY - $projection - $overhang; $x2 = $originX - $offset_fascia; $y2 = $originY; dxf_line($x1,$y1,$x2,$y2); # draw right fascia line at 45 wall $x1 = $originX + $projection + $face_wall + $offset; $y1 = $originY - $projection - $overhang; $x2 = $originX + $projection + $face_wall + $projection + $offset_fascia; $y2 = $originY; dxf_line($x1,$y1,$x2,$y2); # draw back wall zero tail left rafter $x1 = $originX; $y1 = $originY; $x2 = $originX - $offset_zero_fascia; $y2 = $originY - $offset_zero_fascia; dxf_line($x1,$y1,$x2,$y2); # draw back wall zero tail right rafter $x1 = $originX + $projection + $face_wall + $projection; $y1 = $originY; $x2 = $originX + $projection + $face_wall + $projection + $offset_zero_fascia; $y2 = $originY - $offset_zero_fascia; dxf_line($x1,$y1,$x2,$y2); # draw face wall king common $x1 = $originX + $major_common_rafter_run; $y1 = $originY - $projection - $overhang; $x2 = $originX + $major_common_rafter_run; $y2 = $originY - $projection - $overhang + $minor_common_rafter_run_to_fascia; dxf_line($x1,$y1,$x2,$y2); # draw jack rafters on face wall if($face_wall_half >= $jack_spacing){ # draw face wall left jack rafter $max = floor($face_wall_half / $jack_spacing); for($i=1; $i<= $max; $i++){ $jack_offset = (($face_wall_half-$bay_hip_rafter_offset_at_face_wall_corner) - ($jack_spacing * $i)) * tan($bay_hip_rafter_run_bisect_angle_deg * $DEGREE_TO_RAD); $x1 = $originX + $major_common_rafter_run - ($jack_spacing * $i); $y1 = $originY - $projection - $overhang; $x2 = $originX + $major_common_rafter_run - ($jack_spacing * $i); $y2 = $originY - $projection + $jack_offset; dxf_line($x1,$y1,$x2,$y2); $common_jackrafter_length = $jack_offset / cos(atan($minor_pitch / 12)); print "\n\n Face Wall Common Jack Rafter # $i = " .convertTOfeet($common_jackrafter_length) if($common_jackrafter_length > 0); # draw face wall right jack rafter $x1 = $originX + $major_common_rafter_run + ($jack_spacing * $i); $y1 = $originY - $projection - $overhang; $x2 = $originX + $major_common_rafter_run + ($jack_spacing * $i); $y2 = $originY - $projection + $jack_offset; dxf_line($x1,$y1,$x2,$y2); } } $rx1 = $originX + $major_common_rafter_run; $ry1 = $originY - $projection + $minor_common_rafter_run; $wall_45_king_common_total_run = ($bay_hip_rafter_run + $overhang_bay_hip_run) * cos($bay_hip_rafter_run_bisect_adj_top_angle_deg * $DEGREE_TO_RAD); # $px1 and $py1 are radius points from the hip intersection at the ridge to the 45 wall king common at fascia line $px1 = $wall_45_king_common_total_run * cos(45 * $DEGREE_TO_RAD); $py1 = $wall_45_king_common_total_run * sin(45 * $DEGREE_TO_RAD); $fx1 = $originX + $major_common_rafter_run - $px1; # left 45 wall king common at fascia line $fy1 = $originY - $projection + $minor_common_rafter_run - $py1; # left 45 wall king common at fascia line $sfx1 = $fx1; $sfy1 = $fy1; $sfx2 = $originX + $major_common_rafter_run + $px1; # right 45 wall king common at fascia line $sfy2 = $originY - $projection + $minor_common_rafter_run - $py1; # right 45 wall king common at fascia line # draw left 45 wall king common $x1 = $originX + $major_common_rafter_run; $y1 = $originY - $projection + $minor_common_rafter_run; $x2 = $fx1; $y2 = $fy1; dxf_line($x1,$y1,$x2,$y2) if($king_offset >= 0); # draw right 45 wall king common $x1 = $originX + $major_common_rafter_run; $y1 = $originY - $projection + $minor_common_rafter_run; $x2 = $originX + $major_common_rafter_run + $px1; $y2 = $originY - $projection + $minor_common_rafter_run - $py1; $sfx2 = $x2; $sfy2 = $y2; dxf_line($x1,$y1,$x2,$y2) if($king_offset >= 0); # draw jack rafters on 45 wall to front face wall bay hip rafter if($king_projection_wall_length >= $jack_spacing){ # draw 45 wall jack rafters $max = floor($king_offset / $jack_spacing); if($king_offset >= $jack_spacing){ for($i=1; $i<= $max; $i++){ # front side jack rafters $t_length = ($jack_spacing * $i) / cos($bay_hip_rafter_run_bisect_adj_angle_deg * $DEGREE_TO_RAD); $jack_offset = (($jack_spacing * $i)) * tan($bay_hip_rafter_run_bisect_adj_angle_deg * $DEGREE_TO_RAD); $common_jackrafter_length = $wall_common_rafter_length - ($jack_offset / cos($Minor_Pitch)); print "\n\n 45 Wall Common Jack Rafter # $i = " .convertTOfeet($common_jackrafter_length) if($common_jackrafter_length > 0); $pxx1 = $t_length * cos($bay_hip_rafter_run_bisect_angle_deg * $DEGREE_TO_RAD); $pyy1 = $t_length * sin($bay_hip_rafter_run_bisect_angle_deg * $DEGREE_TO_RAD); $px1 = ($jack_spacing * $i) * cos(45 * $DEGREE_TO_RAD); $py1 = ($jack_spacing * $i) * sin(45 * $DEGREE_TO_RAD); $x1 = $originX + $major_common_rafter_run - $pxx1; $y1 = $originY - $projection + $minor_common_rafter_run - $pyy1; $x2 = $sfx1 + $px1; $y2 = $sfy1 - $py1; dxf_line($x1,$y1,$x2,$y2); # front side left $x1 = $originX + $major_common_rafter_run + $pxx1; $y1 = $originY - $projection + $minor_common_rafter_run - $pyy1; $x2 = $sfx2 - $px1; $y2 = $sfy2 - $py1; dxf_line($x1,$y1,$x2,$y2); # front side right } } $max = floor(($king_projection_wall_length ) / $jack_spacing); for($i=1; $i<= $max; $i++){ # back side jackrafters -- back bay hip is at different angle than the front face wall bay hip rafters $t_length = ($jack_spacing * $i) / cos(45 * $DEGREE_TO_RAD); $jack_offset = ($king_projection_wall_length - ($jack_spacing * $i)) * tan(45 * $DEGREE_TO_RAD); $common_jackrafter_length = $jack_offset / cos($Minor_Pitch); print "\n\n 45 Wall Back Common Jack Rafter # $i = " .convertTOfeet($common_jackrafter_length) if($common_jackrafter_length > 0); $pxx1 = $t_length; # point at hip $pyy1 = 0; # point at hip $px1 = ($jack_spacing * $i) * cos(45 * $DEGREE_TO_RAD); # point at fascia line $py1 = ($jack_spacing * $i) * sin(45 * $DEGREE_TO_RAD); # point at fascia line $x1 = $originX + $major_common_rafter_run - $pxx1; # point at hip $y1 = $originY - $projection + $minor_common_rafter_run - $pyy1; # point at hip $x2 = $sfx1 - $px1; # point at fascia line $y2 = $sfy1 + $py1; # point at fascia line dxf_line($x1,$y1,$x2,$y2); # back side left $x1 = $originX + $major_common_rafter_run + $pxx1; # point at hip $y1 = $originY - $projection + $minor_common_rafter_run - $pyy1; # point at hip $x2 = $sfx2 + $px1; # point at fascia line $y2 = $sfy2 + $py1; # point at fascia line dxf_line($x1,$y1,$x2,$y2); # back side right } } $str= "ENDSEC\n0\nEOF"; print FILE $str; close FILE; exit; ################################### # library sub routines follow ################################### # [Ctrl]+E for zoom extents sub dxf_line { my ($x1,$y1,$x2,$y2) = @_; $color=0; $dxf_line_count++; $str = sprintf("LINE\n5\n%dD\n8\n%d\n6\nCONTINOUS\n62\n%d\n10\n%lf\n20\n%lf\n30\n0.0\n11\n%lf\n21\n%lf\n31\n0.0\n0\n", $dxf_line_count,$DXF_LAYER,$DFX_COLOR,$x1,$y1,$x2,$y2); #print $str; print FILE $str; } #=============================================================================# sub escape_string { my($esc) = @_; $esc =~ s/([^a-zA-Z0-9_\-.])/uc sprintf("%%%02x",ord($1))/eg; $esc =~ s/ /+/g; return $esc; } #=============================================================================# sub get_dxf_header_file{ my($file)=shift; my $header; open(FH, "<$file") || die("$file: Can't open because ($!)."); while(){ $header .= $_; } close(FH); return $header; } #=============================================================================# sub hypot{ my ($x,$y) = @_; my $s = sqrt( $x* $x + $y * $y); return $s; } #=============================================================================# sub convertTOfeet{ my ($decimal) = @_; return $decimal unless $show_feet_inches eq 'yes'; #print "\n inches decimal = " .$decimal; my $wholefeet = floor($decimal/12); my $wholeinch = floor($decimal - ($wholefeet*12)); my $decimalfrac = ($decimal*1) - floor($decimal); my ($frac1,$frac2,$frac_str); $frac2 = 16; if ($decimalfrac >= 0.9774) # 15/16 = 0.9375 { $wholeinch++; $decimalfrac = 0.00; if($wholeinch == 12) { $wholefeet++; $wholeinch = 0; } } if ($decimalfrac > 0.0001) { $frac1 = $decimalfrac * $frac2; my $wholefrac = floor($decimalfrac * $frac2); $frac1 = ceil($decimalfrac * $frac2); $frac1 = 15 if($frac1 == 16); ($frac1,$frac2) = check_frac($frac1,$frac2); $frac_str = sprintf(" %d/%d",$frac1,$frac2); } my $str = sprintf("%d'-%d%s''", $wholefeet,$wholeinch,$frac_str); return $str; } #=============================================================================# sub check_frac{ my ($numerator ,$denominator) = @_; return (7,8) if $numerator eq 14; return (3,4) if $numerator eq 12; return (5,8) if $numerator eq 10; return (1,2) if $numerator eq 8; return (3,8) if $numerator eq 6; return (1,4) if $numerator eq 4; return (1,8) if $numerator eq 2; return ("","") if $numerator eq 0; return ("","") if $denominator eq 0; return ($numerator ,$denominator); } #=============================================================================# sub roundAngle{ my ($angle) = @_; my $str = sprintf("%.2f",$angle); return $str; } #=============================================================================# sub roundAngle_5{ my ($angle) = @_; my $str = sprintf("%.5f",$angle); return $str; } #=============================================================================# sub convertTOpitch{ my ($decimal) = @_; my $wholefeet = floor($decimal/12); my $wholeinch = floor($decimal - ($wholefeet*12)); my $decimalfrac = ($decimal*1) - floor($decimal); my ($frac1,$frac2,$frac_str); $frac2 = 16; if ($decimalfrac >= 0.9774) # 15/16 = 0.9375 { $wholeinch++; $decimalfrac = 0.00; if($wholeinch == 12) { $wholefeet++; $wholeinch = 0; } } if ($decimalfrac > 0.0001) { $frac1 = $decimalfrac * $frac2; my $wholefrac = floor($decimalfrac * $frac2); $frac1 = ceil($decimalfrac * $frac2); $frac1 = 15 if($frac1 == 16); ($frac1,$frac2) = check_frac($frac1,$frac2); $frac_str = sprintf(" %d/%d",$frac1,$frac2); } my $str = sprintf("%d%s", $wholeinch,$frac_str); return $str; } #===================================================================# sub read_input { my($buffer) = undef; my ($item); if ($ENV{'REQUEST_METHOD'} eq 'POST') { read(STDIN,$buffer,$ENV{'CONTENT_LENGTH'}); } else { $buffer=$ENV{'QUERY_STRING'}; } $buffer = $ARGV[0] if (not $buffer); my @pairs=split(/&/,$buffer); foreach $item(@pairs) { my ($key,$content)=split (/=/,$item,2); # Split into key and value. $content =~ tr/+/ /; # Convert plus's to spaces $content =~ s/%(..)/pack("c",hex($1))/ge; # Convert %XX from hex numbers to alphanumeric $content =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; # prevent hackers from exploiting the input name $key =~ tr/+/ /; # Convert plus's to spaces $key =~ s/%(..)/pack("c",hex($1))/ge; # Convert %XX from hex numbers to alphanumeric $key =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $key =~ s/ /_/g; # get rid of attempts to insert HTML tags $content =~ s///g; # server-side-includes $content =~ s/<([^>]|\n)*>//gs; $content =~ s//>/g; # get rid of attempts to insert illegal characters $content =~ s/\\//g; # remove black slashes $content =~ s/\0//g; # remove nulls $content =~ s/[\\\&\;\`\'\"\|\*\?\~\^\[\]\{\}\$]//gs; $content =~ s/\cM/\n/g; #convert CR to LF $content =~ s/^\s+|\s+$//gs; $content = substr($content,0,4096); $data{$key} = $content; } return 1; }