|
28 | 28 | <p class="Normal">A VPython <a href="VPython_Intro.pdf" target="_blank">tutorial</a></p> |
29 | 29 | <p class="Normal"><a href="videos.html">Introductory Videos</a></p> |
30 | 30 | <p class="Normal"><a href="primitives.html">Pictures</a> of 3D objects</p> |
31 | | -<p><select id="menu1" onchange="jumpMenu(this)"></select></p> |
32 | | -<p><select id="menu2" onchange="jumpMenu(this)"></select></p> |
33 | | -<p><select id="menu3" onchange="jumpMenu(this)"></select></p> |
| 31 | +<p><select id="menu1" onChange="jumpMenu(this)"></select></p> |
| 32 | +<p><select id="menu2" onChange="jumpMenu(this)"></select></p> |
| 33 | +<p><select id="menu3" onChange="jumpMenu(this)"></select></p> |
34 | 34 |
|
35 | 35 | <p class="Normal"><a href="new_features.html">What's new</a></p> |
36 | 36 | <p class="Normal"><a href="http://vpython.org" target="_blank">Classic VPython web site</a><br /> |
@@ -74,18 +74,22 @@ <h1 class="Heading-1"> <font color="#0000A0">Math Functions</font></h1> |
74 | 74 | max(a,b,c,..) # maximum of these<br /> |
75 | 75 | min(a,b,c,..) # minimum of these</p> |
76 | 76 | <p class="Normal">Many of the quantities above are short forms of the JavaScript functions Math.abs(x), Math.sqrt(x), etc. <strong><a href="factorial.html">Here are details</a></strong> of the factorial and combin functions.</p> |
| 77 | + <p class="Normal"> </p> |
| 78 | + <p class="Normal">In general, Python modules cannot be imported into VPython programs, because GlowScript VPython functions in a JavaScript environment. However, one can import the Python "random" module into a VPython program, provided by the RapydScript-NG tool that converts Python to JavaScript. One cannot use the form "from random import *" but must use "import random" or "import random as rr" (or other name) or "from random import randint, uniform" (or other list of functions). Here is <strong><a href="https://docs.python.org/3/library/random.html">documentation</a></strong> of the Python random module. You do not need to import the random module in order to be able to use the random() function described above.</p> |
| 79 | + <p class="Normal"> </p> |
77 | 80 | <p class="Normal">There are functions for converting between degrees and |
78 | 81 | radians, where there are 2*pi radians in 360 degrees: </p> |
79 | 82 | <p class="program">radians(360) # equal to 2*pi<br /> |
80 | | - degrees(2*pi) # equal to 360</p> |
| 83 | + degrees(2*pi) # equal to 360 </p> |
| 84 | + <p class="Normal"> </p> |
81 | 85 | <p class="Normal">See JavaScript documentation on the <strong><a href="http://www.w3schools.com/jsref/jsref_obj_date.asp" target="_blank">Date</a></strong> object which provides methods for determining the current day etc. </p> |
82 | 86 | <p class="Normal">Here is a way to determine elapsed time in seconds, with microsecond accuracy, using the clock() function that is also available in the standard Python "time" module. The displayed text is approximately 1.5:</p> |
83 | 87 | <p class="program">t1 = clock()<br /> |
84 | 88 | sleep(1.5)<br /> |
85 | 89 | t2 = clock()<br /> |
86 | | - print(t2-t1)</p> |
87 | | - <p class="Normal"></p> |
| 90 | + print(t2-t1) </p> |
88 | 91 | <p class="Normal">There is also a function msclock() which gives the time in milliseconds instead of seconds.</p> |
| 92 | + <p class="Normal"> </p> |
89 | 93 | <p class="Normal">You can <a href="MathJax.html" target="_blank"><strong>use LaTeX</strong></a> to display mathematical expressions on the page.</p> |
90 | 94 | <br /> |
91 | 95 | <!-- InstanceEndEditable --></td> |
|
0 commit comments