]> git.scottworley.com Git - nt3d/blame - serrated.html
Space fingers uniformly, not by number per ring
[nt3d] / serrated.html
CommitLineData
8d119f4c
SW
1<html>
2 <head>
3 <title>Serrated</title>
4 <script type="text/javascript" src="nt3d.js"></script>
5 <script type="text/javascript">
3bafa9bd 6 function serrated(params) {
8d119f4c 7 var tau = 2 * Math.PI;
3bafa9bd 8 var path_length = params.num_serrations * params.steps_per_serration;
8d119f4c
SW
9 var path = [];
10 for (var i = 0; i <= path_length; i++) {
3bafa9bd 11 path[i] = [params.length*i/path_length,0,0];
8d119f4c 12 }
3bafa9bd 13 var serration_length = params.length / params.num_serrations;
8d119f4c 14 var serration_half_length = serration_length / 2;
3bafa9bd 15 var serration_radius = serration_half_length / Math.sin(tau * params.arc / 2);
8d119f4c
SW
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
3bafa9bd 20 var edge_height = params.thickness / (2 * Math.tan(tau * params.edge_bevel_angle));
8d119f4c 21 function shape(i) {
3bafa9bd 22 var serration_progress = (i % params.steps_per_serration) / params.steps_per_serration;
8d119f4c
SW
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);
3bafa9bd
SW
25 if (params.arc < 0) serration_height *= -1;
26 var blade_height = params.depth + serration_height;
27 return [[0, 0, 0],
28 [blade_height - edge_height, 0, 0],
29 [blade_height, params.thickness/2, 0],
30 [blade_height - edge_height, params.thickness, 0],
31 [0, params.thickness, 0]];
8d119f4c
SW
32 }
33 return nt3d.extrude(path, shape, [1,0,0], [0,0,1]);
34 }
3bafa9bd
SW
35 var params = [["length", 100, ],
36 ["thickness", 2],
37 ["depth", 10],
38 ["num_serrations", 10],
39 ["arc", .2, "Arc of Each Serration (in turns)"],
40 ["steps_per_serration", 11],
41 ["edge_bevel_angle", .05, "Edge Bevel Angle (in turns)"]];
8d119f4c
SW
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>