]> git.scottworley.com Git - nt3d/blob - box_by_rotation.html
Generalize rotate()
[nt3d] / box_by_rotation.html
1 <html>
2 <head>
3 <title>Box by rotation</title>
4 <script type="text/javascript" src="nt3d.js"></script>
5 <script type="text/javascript">
6 function box_by_rotation(size_as_string) {
7 var size = parseFloat(size_as_string);
8 var origin = [0, 0, 0 ];
9 var x = [size, 0, 0 ];
10 var y = [0, size, 0 ];
11 var xy = [size, size, 0 ];
12 var xy_face = nt3d.quad(origin, y, xy, x);
13 return [].concat(
14 xy_face,
15 nt3d.rotate_about_origin(xy_face, nt3d.unit([1,1,1]), 2*Math.PI/3), // yz
16 nt3d.rotate_about_origin(xy_face, nt3d.unit([1,1,1]), -2*Math.PI/3), // xz
17 nt3d.rotate(xy_face, [0.5, 0, 0.5], [0, 1, 0], Math.PI), // far xy (top)
18 nt3d.rotate(xy_face, [1, 1, 0], nt3d.unit([-1, -1, 1]), 2*Math.PI/3), // far yz
19 nt3d.rotate(xy_face, [1, 1, 0], nt3d.unit([-1, -1, 1]), -2*Math.PI/3)); // far xz
20 }
21 var params = [["Size", 1]];
22 </script>
23 </head>
24 <body onload="nt3d.framework(box_by_rotation, params)">
25 <h1>Box by rotation</h1>
26 <p>Make a box by specifying one face, then copy-rotating it five times.</p>
27 </body>
28 </html>