-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
106 lines (91 loc) · 2.54 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<html>
<head>
<link rel="stylesheet" type="text/css" href="lib/jquery-ui-1.12.1/jquery-ui.min.css"></link>
<link rel="stylesheet" type="text/css" href="lib/jquery-ui-1.12.1/jquery-ui.theme.min.css"></link>
<script src="lib/jquery-3.2.1.min.js" type="text/javascript"></script>
<script src="lib/jquery-ui-1.12.1/jquery-ui.js" type="text/javascript"></script>
<script>
let RAD2DEG=Math.PI / 180.0;
var gageSet='metric_103';
var gages = {
metric_103: mk_gage_metric_103()
}
function mk_gage_metric_103()
{
var m = [1.005];
fixed=9;
for(i=1.01; i<=1.49; i+= .01) { m.push(1.0* i.toFixed(fixed)); }
for(i=.5; i<=24.50; i+= .5) { m.push(1.0* i.toFixed(fixed)); }
for(i=25; i<=100; i+= 25) { m.push(1.0* i.toFixed(5)); }
return m.sort(function(a,b) { return a-b} );
//return m.sort(function(a,b) { return b-a} );
}
mCalc = function()
{
var dist = $("#distance").val();
var ang = $("#angle").val();
var stackH = dist*Math.sin(ang * RAD2DEG);
$("#stackHeight").val(stackH.toFixed(5));
var sum = 0;
var blocks = [];
for (var i = gages[gageSet].length-1 ; i >=0 ; i--)
{
var tl = gages[gageSet][i];
console.debug(sum, sum+tl, stackH);
if(Math.abs(sum+tl - stackH) < .00001)
{
sum += tl;
blocks.push(tl);
//console.debug(tl);
break;
} else if(sum+tl +1 <= stackH)
{
sum += tl;
blocks.push(tl);
}
}
for (var i = gages[gageSet].length-1 ; i >=0 ; i--)
{
var tl = gages[gageSet][i];
if(sum+tl <= stackH)
{
sum += tl;
blocks.push(tl);
}
}
$("#oStack").html(blocks.join("<br>") + "<br>=" + sum);
console.debug(sum, tl);
};
$(document).ready(function() {
mEvent="keyup";
var dSlider = $("#Sdistance").slider({
min: 1
, max: 200
, step: .1
, value: 70
, slide: function(e,u) { $("#distance").val(u.value); mCalc(); }
});
//mEvent="change";
$("#distance").on(mEvent, function() { $("#Sdistance").slider("option", "value", $(this).val()) ; mCalc(); } );
$("#distance").val(75).trigger(mEvent);
$("#Sangle").slider({
min: 1
, max: 90
, step: .1
, value: 45
, slide: function(e,u) { $("#angle").val(u.value) ; mCalc();}
});
$("#angle").on(mEvent, function() { $("#Sangle").slider("option", "value", $(this).val()) ; mCalc(); } );
$("#angle").val(45).trigger(mEvent);
$("#distance").on('change', mCalc);
$("#angle").on('change', mCalc);
//console.debug(gages);
}); // docready
</script>
</head>
<body>
Distance <input id="distance"><div id="Sdistance"></div>
Desired Angle <input id="angle"><div id="Sangle"></div>
Stack height <input id="stackHeight"><div id="oStack"></div>
</body>
</html>