]> git.scottworley.com Git - nt3d/blame_incremental - serrated.html
Start on Medusa.
[nt3d] / serrated.html
... / ...
CommitLineData
1<html>
2 <head>
3 <title>Serrated</title>
4 <script type="text/javascript" src="nt3d.js"></script>
5 <script type="text/javascript">
6 function serrated(length, thickness, depth, serration_count, arc, steps_per_serration, edge_bevel_angle) {
7 var tau = 2 * Math.PI;
8 var path_length = serration_count * steps_per_serration;
9 var path = [];
10 for (var i = 0; i <= path_length; i++) {
11 path[i] = [length*i/path_length,0,0];
12 }
13 var serration_length = length / serration_count;
14 var serration_half_length = serration_length / 2;
15 var serration_radius = serration_half_length / Math.sin(tau * arc / 2);
16 var serration_max_height = Math.sqrt(serration_radius*serration_radius - serration_half_length*serration_half_length);
17 // This emits a Sabre Grind. TODO: Support a double bevel.
18 // http://en.wikipedia.org/wiki/Grind#Typical_grinds
19 // http://www.allaboutpocketknives.com/images/aapk_content/blade_bevel.JPG
20 var edge_height = thickness / (2 * Math.tan(tau * edge_bevel_angle));
21 function shape(i) {
22 var serration_progress = (i % steps_per_serration) / steps_per_serration;
23 var serration_x = serration_progress * serration_length - serration_half_length;
24 var serration_height = serration_max_height - Math.sqrt(serration_radius*serration_radius - serration_x*serration_x);
25 if (arc < 0) serration_height *= -1;
26 var blade_height = depth + serration_height;
27 return [[0, 0, 0],
28 [blade_height - edge_height, 0, 0],
29 [blade_height, thickness/2, 0],
30 [blade_height - edge_height, thickness, 0],
31 [0, thickness, 0]];
32 }
33 return nt3d.extrude(path, shape, [1,0,0], [0,0,1]);
34 }
35 var params = [["Blade length", 100],
36 ["Blade thickness", 2],
37 ["Blade depth", 10],
38 ["Number of serrations", 10],
39 ["Arc of each serration (in turns)", .2],
40 ["Steps per serration", 11],
41 ["Edge bevel angle (in turns)", .05]];
42 </script>
43 </head>
44 <body onload="nt3d.framework(serrated, params)">
45 <h1>Serrated</h1>
46 <p>Make a serrated blade.</p>
47 </body>
48</html>