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