diff --git a/files.html b/files.html index 1c1157d1386c0343af3b7b689a2b7758bab76d74..792ef7417003487f4eac291c10718ac532ea58fb 100644 --- a/files.html +++ b/files.html @@ -67,6 +67,7 @@ <a href='./modules/frep/shapes/2D/circle'>circle</a><br> <a href='./modules/frep/shapes/2D/function'>function</a><br> <a href='./modules/frep/shapes/2D/involute%20gear'>involute gear</a><br> + <a href='./modules/frep/shapes/2D/involute%20rack'>involute rack</a><br> <a href='./modules/frep/shapes/2D/polygon'>polygon</a><br> <a href='./modules/frep/shapes/2D/rectangle'>rectangle</a><br> <a href='./modules/frep/shapes/2D/right%20triangle'>right triangle</a><br> diff --git a/modules/frep/shapes/2D/involute rack b/modules/frep/shapes/2D/involute rack new file mode 100644 index 0000000000000000000000000000000000000000..093b3f1ed2a4d1577af9aea3f0e25960c9525f47 --- /dev/null +++ b/modules/frep/shapes/2D/involute rack @@ -0,0 +1,193 @@ +// +// frep involute gear +// +// Neil Gershenfeld +// (c) Massachusetts Institute of Technology 2018 +// +// This work may be reproduced, modified, distributed, performed, and +// displayed for any purpose, but must acknowledge the mods +// project. Copyright is retained and must be preserved. The work is +// provided as is; no warranty is provided, and users accept all +// liability. +// +// closure +// +(function(){ +// +// module globals +// +var mod = {} +// +// name +// +var name = 'frep involute gear' +// +// initialization +// +var init = function() { + mod.module.value = '1' + mod.angle.value = '20' + mod.teeth.value = '10' + } +// +// inputs +// +var inputs = { + variables:{type:'', + event:function(evt){ + for (var p in evt.detail) + mod[p].value = evt.detail[p] + outputs.variables.event() + outputs.shape.event() + }}} +// +// outputs +// +var outputs = { + shape:{type:'', + event:function(){ + var module = parseFloat(mod.module.value) + var angle = Math.PI*parseFloat(mod.angle.value)/180 + var teeth = parseFloat(mod.teeth.value) + // + // pitch radius + // + var rp = module*teeth/2 + mod.info.innerHTML = `pitch radius: ${rp.toFixed(3)} mm<br>` + // + // base radius + // + var rb = rp*Math.cos(angle) + mod.info.innerHTML += `base radius: ${rb.toFixed(3)} mm<br>` + // + // addendum height + // + var ha = 1.0*module + mod.info.innerHTML += `outer radius: ${(rp+ha).toFixed(3)} mm<br>` + // + // dedendum height + // + var hd = 1.1*module + mod.info.innerHTML += `root radius: ${(rp-hd).toFixed(3)} mm<br>` + // + // involute angle + // + var ai = Math.tan(angle)-angle + mod.info.innerHTML += `inv angle: ${(ai*180/Math.PI).toFixed(3)} deg<br>` + // + // pitch angle + // + var ap = 2*Math.PI/teeth + mod.info.innerHTML += `pitch angle: ${(ap*180/Math.PI).toFixed(3)} deg<br>` + // + // shapes + // + // must be inside tip + // + var fn = `${rp}+${ha}-Math.sqrt(X*X+Y*Y)` + // + // angle must be above bottom involute + // + var fn = `Math.min(${fn},(Math.PI+Math.atan2(Y,X))%${ap}-(Math.sqrt(Math.pow(Math.max(${rb},Math.sqrt(X*X+Y*Y))/${rb},2)-1)-Math.acos(${rb}/Math.max(${rb},Math.sqrt(X*X+Y*Y)))))` + // + // angle must be below top involute + // + var fn = `Math.min(${fn},-(Math.sqrt(Math.pow(Math.max(${rb},Math.sqrt(X*X+Y*Y))/${rb},2)-1)-Math.acos(${rb}/Math.max(${rb},Math.sqrt(X*X+Y*Y))))-(-${ap/2+2*ai}+(Math.PI+Math.atan2(Y,X))%${ap}))` + // + // root circle + // + var fn = `Math.max(${fn},${rp-hd}-Math.sqrt(X*X+Y*Y))` + // + // todo: fillets + // + // output + // + var variables = ['X','Y'] + var limits = [[-rp-ha,+rp+ha],[-rp-ha,+rp+ha]] + var type = 'Magnitude' + var shape = {function:fn,variables:variables,limits:limits,type:type} + mods.output(mod,'shape',shape)}}, + +/* +angle = +-(sqrt((r/rb)^2 - 1) - acos(rb/r)) (r > rb) +(x % n + n) % n +*/ + + variables:{type:'', + event:function(){ + var module = parseFloat(mod.module.value) + var angle = parseFloat(mod.angle.value) + var teeth = parseFloat(mod.teeth.value) + var vars = {module:module,angle:angle,teeth:teeth} + mods.output(mod,'variables',vars)} + }} +// +// interface +// +var interface = function(div){ + mod.div = div + // + // module + // + div.appendChild(document.createTextNode('module (mm): ')) + var input = document.createElement('input') + input.type = 'text' + input.size = 3 + div.appendChild(input) + mod.module = input + div.appendChild(document.createElement('br')) + // + // angle + // + div.appendChild(document.createTextNode('pressure angle: ')) + var input = document.createElement('input') + input.type = 'text' + input.size = 3 + div.appendChild(input) + mod.angle = input + div.appendChild(document.createElement('br')) + // + // teeth + // + div.appendChild(document.createTextNode('number of teeth: ')) + var input = document.createElement('input') + input.type = 'text' + input.size = 3 + div.appendChild(input) + mod.teeth = input + div.appendChild(document.createElement('br')) + // + // info + // + var info = document.createElement('span') + div.appendChild(info) + mod.info = info + // + // output button + // + var btn = document.createElement('button') + btn.style.padding = mods.ui.padding + btn.style.margin = 1 + btn.appendChild(document.createTextNode('output')) + btn.addEventListener('click',function(){ + outputs.variables.event() + outputs.shape.event() + }) + div.appendChild(btn) + } +// +// local functions +// +; +// +// return values +// +return ({ + mod:mod, + name:name, + init:init, + inputs:inputs, + outputs:outputs, + interface:interface + }) +}()) diff --git a/modules/index.js b/modules/index.js index 42083bc04eb997ea624c5283a51dc54b4d08b02f..70a483c6e8229869459e73c359754071d6f2361a 100644 --- a/modules/index.js +++ b/modules/index.js @@ -38,6 +38,7 @@ module_menu(' arc','modules/frep/shapes/2D/arc') module_menu(' circle','modules/frep/shapes/2D/circle') module_menu(' function','modules/frep/shapes/2D/function') module_menu(' involute gear','modules/frep/shapes/2D/involute%20gear') +module_menu(' involute rack','modules/frep/shapes/2D/involute%20rack') module_menu(' polygon','modules/frep/shapes/2D/polygon') module_menu(' rectangle','modules/frep/shapes/2D/rectangle') module_menu(' right triangle','modules/frep/shapes/2D/right%20triangle')