 /* Beam bending calc.
Copyright 2007 by Dale Heatherington    (coded June 5, 2007) */
/*********************************/
function beambend_rectangle(dataform,force,length,width,height,E)
{ var I;
var D;
I = ((height*height*height) * width ) / 12;             /* Moment of inertia for rectangle*/
D = ((length*length*length) * force) / (3 * E * I);   /* Deflection */
dataform.D.value = D; 

/* now do bending stress */
var sb;
sb = ( force * length) / ( I / (0.5*height)) ;

dataform.SB.value = sb ;


}
/***********************/
function beambend_rectangletube(dataform,force,length,width,height,wall,E)
{ var I;
var iw,ih;
var D;
iw = width - (2*wall);
ih = height - (2*wall);
I = (((height*height*height) * width) - ((ih*ih*ih)*iw) ) / 12;    /* Moment of inertia for hollow rectangle*/
D = ((length*length*length) * force) / (3 * E * I);                   /* Deflection */
dataform.D.value = D; 

/* now do bending stress */
var sb;
sb = ( force * length) / ( I / (.5*height)) ;

dataform.SB.value = sb ;
}

/*****************************/
function beambend_round(dataform,force,length,diameter,E)
{ var I;
var D;
I = (Math.PI * diameter * diameter * diameter * diameter) / 64 ;     /* 2nd Moment of inertia for round rod */
D = ((length*length*length) * force) / (3 * E * I);                              /* Deflection */
dataform.D.value = D; 

/* now do bending stress */
var sb;
sb = ( force * length) / ( I / (.5*diameter)) ;

dataform.SB.value = sb ;



}
/***********************/
function beambend_roundtube(dataform,force,length,OD,wall,E)
{
var OD4 = OD * OD * OD * OD;
var ID = OD - (2*wall);
if(ID < 0) ID = 0;
var ID4 = ID * ID * ID * ID;
I = ( Math.PI * (OD4 - ID4)) / 64;                           /* 2nd moment of inertia for round tube */
D = ((length*length*length) * force) / (3 * E * I);     /* Deflection */
dataform.D.value = D;
/* now do bending stress */
var sb;
sb = ( force * length) / ( I / (.5*OD)) ;

dataform.SB.value = sb ;


 }
/***********************/
function material_choices_menu() /* Provides E (modulas of elasticity) for various materials */
{
var data = "Material <select name='material'>";
data += "<option value='30000000'> Steel<\/option>";
data += "<option value='16000000'> Titanium<\/option>"; 
data += "<option value='16000000'> Brass<\/option>";
data += "<option value='10500000'> Aluminum<\/option>";
data += "<option value='27000000'> Carbon Fiber<\/option>";
data += "<option value='2700000'> Garolite (G-10/FR-4)<\/option>";
data += "<option value='333000'> Polycarbonate<\/option>";
data += "<option value='300000'> Nylon<\/option>";
data += "<option value='110000'> UHMW<\/option>";
data += "<option value='1700000'> Wood<\/option>"; data += "<\/select>";
document.write(data);
}

