| OLD | NEW |
| 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
| 2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | 2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 3 <html> | 3 <html> |
| 4 <!-- Copyright 2008 Google Inc. All rights reserved. --> | 4 <!-- Copyright 2008 Google Inc. All rights reserved. --> |
| 5 <head> | 5 <head> |
| 6 <title>Monte Carlo Estimate for Pi</title> | 6 <title>Monte Carlo Estimate for Pi</title> |
| 7 <META HTTP-EQUIV="Pragma" CONTENT="no-cache"> | 7 <META HTTP-EQUIV="Pragma" CONTENT="no-cache"> |
| 8 <META HTTP-EQUIV="Expires" CONTENT="-1"> | 8 <META HTTP-EQUIV="Expires" CONTENT="-1"> |
| 9 </head> | 9 </head> |
| 10 <body id="bodyId" onload="doOnLoad()" onunload="doOnUnload()"> | 10 <body id="bodyId" onload="doOnLoad()" onunload="doOnUnload()"> |
| 11 <h1>Monte Carlo Estimate for Pi</h1> | 11 <h1>Monte Carlo Estimate for Pi</h1> |
| 12 <p> | 12 <p> |
| 13 The Native Client module executed in this page creates a thread | 13 The Native Client module executed in this page creates a thread |
| 14 that estimates pi (π) using the Monte Carlo method. | 14 that estimates pi (π) using the Monte Carlo method. |
| 15 The thread randomly puts 1,000,000,000 points | 15 The thread randomly puts 1,000,000,000 points |
| 16 inside a square that shares two sides with a quarter circle (a quadrant). | 16 inside a square that shares two sides with a quarter circle (a quadrant). |
| 17 Because the area of | 17 Because the area of |
| 18 the quadrant is r²π/4 | 18 the quadrant is r²π/4 |
| 19 and the area of | 19 and the area of |
| 20 the square is r², | 20 the square is r², |
| 21 dividing the number of points inside the quadrant | 21 dividing the number of points inside the quadrant |
| 22 by the number of points inside the square gives us | 22 by the number of points inside the square gives us |
| 23 an estimate of π/4. | 23 an estimate of π/4. |
| 24 The textbox under the square | 24 The textbox under the square |
| 25 shows the current estimate of π. | 25 shows the current estimate of π. |
| 26 </p> | 26 </p> |
| 27 <embed id="nacl" src="npapi_pi.nexe" type="application/x-nacl-npapi" | 27 <embed id="nacl" nexe="npapi_pi" type="application/x-nacl-npapi" |
| 28 width="480" height="480" /> | 28 width="480" height="480"> |
| 29 <noembed> |
| 30 Your browser does not appear to support Native Client. |
| 31 Visit http://code.google.com/p/nativeclient/ to get started. |
| 32 <noembed/> |
| 33 </embed> |
| 29 <br /> | 34 <br /> |
| 30 <form name="form"> | 35 <form name="form"> |
| 31 <input type="text" size="15" name="pi" /> | 36 <input type="text" size="15" name="pi" /> |
| 32 </form> | 37 </form> |
| 33 <script type="text/javascript"> | 38 <script type="text/javascript"> |
| 34 <!-- | 39 <!-- |
| 35 var nacl = null; | 40 var nacl = null; |
| 36 var paintInterval = null; | 41 var paintInterval = null; |
| 37 var loadTimer = null; | 42 var loadTimer = null; |
| 38 | 43 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 54 } | 59 } |
| 55 | 60 |
| 56 function doOnUnload() { | 61 function doOnUnload() { |
| 57 clearInterval(paintInterval); | 62 clearInterval(paintInterval); |
| 58 clearTimeout(loadTimer); | 63 clearTimeout(loadTimer); |
| 59 } | 64 } |
| 60 --> | 65 --> |
| 61 </script> | 66 </script> |
| 62 </body> | 67 </body> |
| 63 </HTML> | 68 </HTML> |
| OLD | NEW |