1 | <html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" > |
---|
2 | <head> |
---|
3 | <title>Dojo 3D Vector</title> |
---|
4 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
---|
5 | <style type="text/css"> |
---|
6 | @import "../../../dojo/resources/dojo.css"; |
---|
7 | @import "../../../dijit/tests/css/dijitTests.css"; |
---|
8 | </style> |
---|
9 | <script type="text/javascript" src="../../../dojo/dojo.js" data-dojo-config="isDebug: true"></script> |
---|
10 | <script type="text/javascript"> |
---|
11 | |
---|
12 | dojo.require("dojox.gfx3d.vector"); |
---|
13 | |
---|
14 | pdebug = function(point){ |
---|
15 | console.debug("x: " + point.x + ", y: " + point.y + ", z: " + point.z); |
---|
16 | }; |
---|
17 | |
---|
18 | dojo.addOnLoad(function(){ |
---|
19 | var m = dojox.gfx3d.vector; |
---|
20 | console.debug("test crossProduct..."); |
---|
21 | c = m.crossProduct(1, 2, 3, 4, 5, 6); |
---|
22 | pdebug(c); |
---|
23 | a = {x: 1, y: 2, z: 3}; |
---|
24 | b = {x: 4, y: 5, z: 6}; |
---|
25 | c = m.crossProduct(a, b); |
---|
26 | pdebug(c); |
---|
27 | |
---|
28 | console.debug("test dotProduct..."); |
---|
29 | c = m.dotProduct(1, 2, 3, 4, 5, 6); |
---|
30 | console.debug(c); |
---|
31 | a = {x: 1, y: 2, z: 3}; |
---|
32 | b = {x: 4, y: 5, z: 6}; |
---|
33 | c = m.dotProduct(a, b); |
---|
34 | console.debug(c); |
---|
35 | |
---|
36 | console.debug("test sum/substract..."); |
---|
37 | a = {x: 10, y: 5, z: 8}; |
---|
38 | b = {x: 1, y: 15, z: 2}; |
---|
39 | console.debug(m.sum(a, b)); |
---|
40 | console.debug(m.substract(a, b)); |
---|
41 | |
---|
42 | console.debug("test normalize..."); |
---|
43 | c = {x: 0, y: 17, z: -2}; |
---|
44 | d = m.normalize(a, b, c); |
---|
45 | e = m.normalize([a, b, c]); |
---|
46 | console.debug(d); |
---|
47 | console.debug( "expecting 0:", m.dotProduct(d, m.substract(b, a))); |
---|
48 | console.debug(e); |
---|
49 | console.debug( "expecting 0:", m.dotProduct(e, m.substract(b, a))); |
---|
50 | |
---|
51 | }); |
---|
52 | |
---|
53 | </script> |
---|
54 | </head> |
---|
55 | <body> |
---|
56 | <h1>dojox.gfx3d.vector test</h1> |
---|
57 | <p>Please check the debug console for test results.</p> |
---|
58 | </body> |
---|
59 | </html> |
---|