]>
Commit | Line | Data |
---|---|---|
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(params) { | |
7 | var tau = 2 * Math.PI; | |
8 | var path_length = params.num_serrations * params.steps_per_serration; | |
9 | var path = []; | |
10 | for (var i = 0; i <= path_length; i++) { | |
11 | path[i] = [params.length*i/path_length,0,0]; | |
12 | } | |
13 | var serration_length = params.length / params.num_serrations; | |
14 | var serration_half_length = serration_length / 2; | |
15 | var serration_radius = serration_half_length / Math.sin(tau * params.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 = params.thickness / (2 * Math.tan(tau * params.edge_bevel_angle)); | |
21 | function shape(i) { | |
22 | var serration_progress = (i % params.steps_per_serration) / params.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 (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]]; | |
32 | } | |
33 | return nt3d.extrude(path, shape, [1,0,0], [0,0,1]); | |
34 | } | |
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)"]]; | |
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> |