Created
May 13, 2020 09:49
-
-
Save khorevaa/adeade4d4cad5dbb931e5927efde9fc7 to your computer and use it in GitHub Desktop.
Калькулятор для расчета Юрты
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function yurtcalc() { | |
// -- yurt calculator, written by Rene K. Mueller | |
// for http://Housing.byRene.com | |
// inspired by the dome calculator at DesertDomes.com | |
// history: | |
// 2006-10-29: added piewise canvas calculation | |
// 2006-01-08: volume added | |
// 2005-09-29: htot corrected | |
// 2005-09-27: misc corrections | |
// 2005-08-09: first version | |
var f = document.calc; | |
var h; var d; | |
h = f.h.value*Math.tan(f.akhana.value/2/180*3.141); | |
f.lkhana.value = format(Math.sqrt(f.h.value*f.h.value+h*h)); | |
f.w.value = format(f.d.value*3.141/f.npoles.value); | |
f.wkhanaholes.value = format(f.w.value/(Math.sin(f.akhana.value/180*3.141/2)*2)); | |
f.nkhanaholes.value = Math.floor((f.lkhana.value-12)/f.wkhanaholes.value+1); | |
f.c.value = format(f.d.value*3.141/100); | |
f.apoles.value = format(360/f.npoles.value); | |
f.Awall.value = format((f.d.value/100.0)*3.141*(f.h.value/100.0)); | |
f.Awalld.value = f.c.value+" x "+format(f.h.value/100); | |
if(f.calctype[0].checked) { | |
f.aroof.value = format(Math.atan((f.htot.value-f.h.value)/(f.d.value/2-f.dwheel.value/2))/3.141*180); | |
} else { | |
f.htot.value = format(f.h.value*1+(Math.tan(f.aroof.value/180.0*3.141)*(f.d.value/2-f.dwheel.value/2))); | |
} | |
f.Vtotal.value = format( | |
((f.htot.value-f.h.value)*(f.d.value/2)*(f.d.value/2)*3.141/3 + | |
(f.d.value/2)*(f.d.value/2)*3.141*f.h.value)/(100*100*100)); | |
f.khanaleft.value = Math.round(f.lkhana.value-(f.nkhanaholes.value-1)*f.wkhanaholes.value); | |
f.nkhanasections.value = Math.floor(f.c.value/f.lkhanasection.value)+1; | |
f.nlaths.value = f.npoles.value*2.0+f.nkhanaholes.value*2/2+f.nkhanasections.value*2; | |
d = f.d.value/2-f.dwheel.value/2; | |
h = Math.tan(f.aroof.value/180*3.141)*d; | |
//f.lpole.value = format(Math.pow(h*h+d*d,0.5)); | |
f.lpole.value = format(Math.sqrt(h*h+d*d)); | |
d = f.d.value/2; | |
h = Math.tan(f.aroof.value/180*3.141)*d; | |
//f.lroof.value = format(Math.pow(h*h+d*d,0.5)); | |
f.lroof.value = format(Math.sqrt(h*h+d*d)); | |
f.droof.value = f.lroof.value*2; | |
f.Afloor.value = format((f.d.value/2/100)*(f.d.value/2/100)*3.141); | |
f.Aroof.value = format(((f.lroof.value/100.0))*((f.lroof.value/100.0))*3.141); | |
f.Aroofd.value = format(f.lroof.value*2/100)+" x "+format(f.lroof.value*2/100); | |
f.Arooflo.value = format((f.lroof.value/100*2)*(f.lroof.value/100*2)-f.Aroof.value); | |
f.wwheel.value = format(f.dwheel.value*3.141/f.npoles.value); | |
f.acutoff.value = format((f.lroof.value*2*3.141-f.d.value*3.141)/(f.lroof.value*2*3.141)*360); | |
f.wcutoff.value = format(Math.sin(f.acutoff.value/2/180*3.141)*f.lroof.value*2); | |
var l; var lw = f.wlane.value; var off = 0; var tot = 0; var out = ""; | |
var dr = f.droof.value*1+f.wroofx.value*2; | |
for(l=1; (l+off)*lw<dr; l++) { | |
var w = 0; | |
if(l*lw>=dr/2) { | |
if(off==0) { | |
w = format(dr/100); | |
} | |
off = -1; | |
} | |
if(w==0) { | |
var b = dr/2-(l+off)*lw; | |
w = Math.sqrt((dr/2)*(dr/2)-b*b)*2; | |
w = format(w/100); | |
} | |
tot += w; | |
if(l>1) out += "\n"; | |
out = out+"Lane #"+l+" = "+w+" x "+format(lw/100)+" m"; | |
} | |
f.laneslo.value = w+" x "+format(((l+off)*lw-dr)/100); | |
f.llanestot.value = format(tot)+" x "+format(lw/100); | |
f.lanes.value = out; | |
f.co.value = format(f.d.value*3.141/f.npie.value); | |
f.ci.value = format(f.dwheel.value*3.141/f.npie.value); | |
f.pl.value = f.lpole.value; | |
if(f.h.value*1<=lw) { | |
f.totalcanvas.value = format(tot+f.c.value*1)+" x "+format(lw/100); | |
f.wallnote.value = "one lane"; | |
} else { | |
f.totalcanvas.value = format(tot+(Math.floor(f.c.value*100/lw+1)*f.h.value)/100)+" x "+format(lw/100); | |
f.wallnote.value = Math.floor(f.c.value*100/lw+1)+" lanes"; | |
} | |
f.costcanvas.value = format((tot+f.c.value*1)*f.costpercanvasm.value); | |
f.costkhana.value = format(f.nlaths.value*f.costperkhana.value) | |
f.costpoles.value = format(f.npoles.value*f.costperpole.value); | |
f.totalcost.value = format(f.costcanvas.value*1+f.costkhana.value*1+f.costpoles.value*1); | |
return; | |
} | |
function format(a) { | |
return Math.round(a*100)/100; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment