Skip to content

Commit

Permalink
Merge pull request #6 from trinketapp/v3.2.0
Browse files Browse the repository at this point in the history
V3.2.0
  • Loading branch information
brianpmarks authored Sep 22, 2022
2 parents 1083775 + d71dc3c commit a0cfd87
Show file tree
Hide file tree
Showing 193 changed files with 2,610 additions and 4,437 deletions.
2 changes: 1 addition & 1 deletion ForInstalledPython/glow.min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions GlowScriptOffline/GlowScript.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
<script type="text/javascript" src="glowscript_libraries/jquery.min.js"></script>
<script type="text/javascript" src="glowscript_libraries/jquery-ui.custom.min.js"></script>
<script type="text/javascript" src="glowscript_libraries/editor.js"></script>
<script type="text/javascript" src="glowscript_libraries/RSrun.3.1.min.js"></script>
<script type="text/javascript" src="glowscript_libraries/glow.3.1.min.js" charset="UTF-8"></script>
<script type="text/javascript" src="glowscript_libraries/RSrun.3.2.min.js"></script>
<script type="text/javascript" src="glowscript_libraries/glow.3.2.min.js" charset="UTF-8"></script>
<script type="text/javascript" src="glowscript_libraries/split.min.js"></script>
<script type="text/javascript" src="glowscript_libraries/Roboto_Medium_ttf_sans.js"></script>
<script type="text/javascript" src="glowscript_libraries/NimbusRomNo9L_Med_otf_serif.js"></script>
Expand All @@ -60,7 +60,7 @@
<input type="file" id="read_local_file"/>

<script>
var gsversion = '3.1'
var gsversion = '3.2'
var printpane = false
var exporting = false // not currently in export mode
var lastprintwidth = null
Expand Down
16 changes: 8 additions & 8 deletions GlowScriptOffline/VPythonDocs/MathJax.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!-- InstanceBegin template="/Templates/template.dwt" codeOutsideHTMLIsLocked="false" --><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>VPython Help</title>
<title>MathJax</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->
<link href="VisualRef.css" rel="stylesheet" type="text/css" />
Expand All @@ -12,10 +12,10 @@
<div id="wrapper">
<div id="leftmenu">
<p class="Normal"><a href="index.html">&nbsp;&nbsp;Home</a></p>
<p class="Normal">&nbsp;&nbsp;If you're new to Python <br />
&nbsp;&nbsp;and VPython: <a href="VisualIntro.html">Introduction</a></p>
<p class="Normal">&nbsp;&nbsp;A VPython <a href="VPython_Intro.pdf" target="_blank">tutorial</a></p>
<p class="Normal"><a href="videos.html">&nbsp;&nbsp;Introductory Videos</a></p>
<p class="Normal">&nbsp;&nbsp; <a href="VisualIntro.html">Overview of Python &amp; VPython<br>
</a></p>
<p class="Normal"><a href="https://trinket.io/matter-interactions/courses/00_welcome_to_vpython#/welcome-to-vpython/getting-started">&nbsp;&nbsp;&quot;Welcome to VPython&quot; tutorial</a></p>
<p class="Normal"><a href="videos.html">&nbsp;&nbsp;Introductory Videos</a></p>
<p class="Normal"><a href="primitives.html">&nbsp;&nbsp;Pictures</a> of 3D objects</p>
<p>&nbsp;&nbsp;<select id="menu1" onChange="jumpMenu(this)"></select></p>
<p>&nbsp;&nbsp;<select id="menu2" onChange="jumpMenu(this)"></select></p>
Expand All @@ -30,12 +30,12 @@
<div id="content">
<!-- InstanceBeginEditable name="content" -->
<div>
<h1 class="Heading-1"><font color="#0000A0">Math displays using LaTeX</font> - GlowScript VPython only</h1>
<h1 class="Heading-1"><font color="#0000A0">Math displays using LaTeX</font> - Web VPython only</h1>
</div>
<div>
<p class="Normal">In GlowScript VPython (but not currently in VPython 7) you can display complex mathematical expressions expressed in the widely used math editing format, <a href="http://www.latex-project.org/" target="_blank">LaTeX</a>. Here is <strong><a href="https://www.glowscript.org/#/user/GlowScriptDemos/folder/Examples/program/LaTexMathDisplay" target="_blank">an example</a></strong>. The LaTeX capability is provided by <a href="http://www.mathjax.org/" target="_blank">MathJax</a>, which is imported by GlowScript. For example, consider this mathematical display:</p>
<p class="Normal">In Web VPython (but not currently in VPython 7) you can display complex mathematical expressions expressed in the widely used math editing format, <a href="http://www.latex-project.org/" target="_blank">LaTeX</a>. Here is <strong><a href="https://www.glowscript.org/#/user/GlowScriptDemos/folder/Examples/program/LaTexMathDisplay" target="_blank">an example</a></strong>. The LaTeX capability is provided by <a href="http://www.mathjax.org/" target="_blank">MathJax</a>, which is imported by Web VPython. For example, consider this mathematical display:</p>
<p class="Normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src="images/MathJax.jpg" width="350" height="48" alt="equation" /></p>
<p class="Normal">You can display this in the caption of an existing GlowScript canvas with the following statements:</p>
<p class="Normal">You can display this in the caption of an existing Web VPython canvas with the following statements:</p>
<p class="program"> box()<br />
scene.caption = &quot;Final kinetic energy = \\( \\dfrac {1} {2}mv_i^{2}+\\int _{i}^{f}\\vec{F}\\circ d \\vec{r} \\)&quot;<br />
<br />
Expand Down
8 changes: 4 additions & 4 deletions GlowScriptOffline/VPythonDocs/Templates/template.dwt
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
<div id="wrapper">
<div id="leftmenu">
<p class="Normal"><a href="index.html">&nbsp;&nbsp;Home</a></p>
<p class="Normal">&nbsp;&nbsp;If you're new to Python <br />
&nbsp;&nbsp;and VPython: <a href="VisualIntro.html">Introduction</a></p>
<p class="Normal">&nbsp;&nbsp;A VPython <a href="VPython_Intro.pdf" target="_blank">tutorial</a></p>
<p class="Normal"><a href="videos.html">&nbsp;&nbsp;Introductory Videos</a></p>
<p class="Normal">&nbsp;&nbsp; <a href="VisualIntro.html">Overview of Python &amp; VPython<br>
</a></p>
<p class="Normal"><a href="https://trinket.io/matter-interactions/courses/00_welcome_to_vpython#/welcome-to-vpython/getting-started">&nbsp;&nbsp;&quot;Welcome to VPython&quot; tutorial</a></p>
<p class="Normal"><a href="videos.html">&nbsp;&nbsp;Introductory Videos</a></p>
<p class="Normal"><a href="primitives.html">&nbsp;&nbsp;Pictures</a> of 3D objects</p>
<p>&nbsp;&nbsp;<select id="menu1" onChange="jumpMenu(this)"></select></p>
<p>&nbsp;&nbsp;<select id="menu2" onChange="jumpMenu(this)"></select></p>
Expand Down
75 changes: 38 additions & 37 deletions GlowScriptOffline/VPythonDocs/VisualIntro.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!-- InstanceBegin template="/Templates/template.dwt" codeOutsideHTMLIsLocked="false" --><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>VPython Help</title>
<title>VPython Introduction</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->
<link href="VisualRef.css" rel="stylesheet" type="text/css" />
Expand All @@ -12,10 +12,10 @@
<div id="wrapper">
<div id="leftmenu">
<p class="Normal"><a href="index.html">&nbsp;&nbsp;Home</a></p>
<p class="Normal">&nbsp;&nbsp;If you're new to Python <br />
&nbsp;&nbsp;and VPython: <a href="VisualIntro.html">Introduction</a></p>
<p class="Normal">&nbsp;&nbsp;A VPython <a href="VPython_Intro.pdf" target="_blank">tutorial</a></p>
<p class="Normal"><a href="videos.html">&nbsp;&nbsp;Introductory Videos</a></p>
<p class="Normal">&nbsp;&nbsp; <a href="VisualIntro.html">Overview of Python &amp; VPython<br>
</a></p>
<p class="Normal"><a href="https://trinket.io/matter-interactions/courses/00_welcome_to_vpython#/welcome-to-vpython/getting-started">&nbsp;&nbsp;&quot;Welcome to VPython&quot; tutorial</a></p>
<p class="Normal"><a href="videos.html">&nbsp;&nbsp;Introductory Videos</a></p>
<p class="Normal"><a href="primitives.html">&nbsp;&nbsp;Pictures</a> of 3D objects</p>
<p>&nbsp;&nbsp;<select id="menu1" onChange="jumpMenu(this)"></select></p>
<p>&nbsp;&nbsp;<select id="menu2" onChange="jumpMenu(this)"></select></p>
Expand All @@ -33,11 +33,12 @@ <h1 class="Title" align="center"> <font color="#FF0000">Simple 3D Programming

Using VPython</font> </h1>
<div>
<h3 class="Heading-1"> <font color="#0000A0">I. Getting started</font></h3>
<p class="Normal">To write a VPython program in the browser, sign in at glowscript.org, click the link to your programs, then click Create New Program. A blank edit page will open with a header line that says something like &quot;GlowScript 3.0 VPython&quot;. Start typing your program on the second line. Click &quot;Run this program&quot; to try out your program.</p>
<h3><font color="#0000A0">1: Getting started</font>
</h3>
<p class="Normal">To write a VPython program in the browser, sign in at webvpython.org, click the link to your programs, then click Create New Program. A blank edit page will open with a header line that says something like &quot;Web VPython 3.2&quot;. Start typing your program on the second line. Click &quot;Run this program&quot; to try out your program.</p>
</div>
<div>
<h3 class="Heading2"> <font color="#0000A0">The canvas</font></h3>
<h5 class="Heading2"> <font color="#0000A0">The canvas</font></h5>
<p class="Normal"> When using VPython the canvas shows objects in 3D.</p>
<p class="Normal"> (0,0,0) is in the center of the canvas<img src="axes.gif" alt="axes" align="right" /> . The +x axis runs to the right, the +y axis runs up, and the +z axis points out of the screen, toward you.</p>
<p class="Normal"> x, y, and z are measured in whatever units you choose;
Expand All @@ -50,17 +51,17 @@ <h3 class="Heading2"> <font color="#0000A0">The canvas</font></h3>

to put both of these objects in the same canvas!)</p>

<h3 class="Heading2"> <font color="#0000A0">The Output window</font></h3>
<h5 class="Heading2"> <font color="#0000A0">The Output window</font></h5>
<p class="Normal"> The output of any -print- statements you execute in your program goes to a scrolling text window underneath the graphics window. You can use this window to print values of variables, print lists, print messages, etc.</p>

<h3 class="Heading2"> <font color="#0000A0">The Code window</font></h3>
<h5 class="Heading2"> <font color="#0000A0">The Code window</font></h5>
<p class="Normal">If you type or copy the following simple program into the program editor and run it (click &quot;Run this program&quot; or press Ctrl-1 or Ctrl-2), you will see
a canvas conatining a red box and a green sphere, as shown in the figure. </p>
<p class="program"> redbox=box(pos=vector(4,2,3),<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; size=vector(8,4,6),color=color.red)<br />
ball=sphere(pos=vector(4,7,3),radius=2,color=color.green)</p>
<p class="Normal"> <span class="Heading-1"><img src="spherebox.gif" alt="sphere" align="right" /></span></p>
<h3 class="Heading2"><font color="#0000A0">Viewing the scene</font></h3>
<h5 class="Heading2"><font color="#0000A0">Viewing the scene</font></h5>
<p class="Normal"> In the canvas, click and drag with the right mouse
button (or hold down the Ctrl key while dragging). Drag left or right, and
you rotate around the scene. To rotate around a horizontal axis, drag up
Expand All @@ -69,9 +70,10 @@ <h3 class="Heading2"><font color="#0000A0">Viewing the scene</font></h3>
mouse, hold down the left and right buttons; on a 1-button mouse, hold down
the Alt key). To pan left/right and up/down, drag with the shift key held down.</p>

<h3 class="Heading-1"> <font color="#0000A0">II. VPython Entities</font></h3>

<h3 class="Heading2"> <font color="#0000A0">Objects, names, and attributes</font></h3>
<h3><font color="#0000A0">2: VPython Entities</font>

</h3>
<h5 class="Heading2"> <font color="#0000A0">Objects, names, and attributes</font></h5>
<p class="Normal"> The graphical objects you create, such as spheres, boxes,

and curves, continue to exist for the duration of your program, and the
Expand All @@ -98,8 +100,7 @@ <h3 class="Heading2"> <font color="#0000A0">Objects, names, and attributes</font
in addition to its radius and location, you might give it attributes such

as mass (<span class="attribute">moon.mass</span>) and momentum (<span class="attribute">moon.momentum</span>).</p>
<h3 class="Heading2"><font color="#0000A0">Vectors</font> </h3>
<p class="program"></p>
<h5 class="Heading2"><font color="#0000A0">Vectors</font> </h5>
<p class="Normal"><span class="Normal">Not all objects in VPython are visible objects. For example,

VPython allows you to create 3D vector quantities, and to perform vector
Expand All @@ -115,38 +116,39 @@ <h3 class="Heading2"><font color="#0000A0">Vectors</font> </h3>
<p class="Normal"> If you include print(c), you will see that

it is a vector with components &lt;5, 7, 9&gt;.</p>
<h3 class="Heading2"><font color="#0000A0">Scalar multiplication</font></h3>
<p class="program">d = 3*a # d is a vector with components &lt;3, 6, 9&gt;</p>
<h5 class="Heading2"><font color="#0000A0">Scalar multiplication</font></h5>
<p class="program">d = 3*a # d is a vector with components &lt;3, 6, 9&gt;</p>

<h3 class="Heading2"><font color="#0000A0">Vector magnitude</font> </h3>
<h5 class="Heading2"><font color="#0000A0">Vector magnitude</font> </h5>
<p class="program">s = mag(c) &nbsp;&nbsp;&nbsp;# s is a scalar magnitude<br />
z = mag(c)**2 # square the magnitude of the vector; ** means &quot;to the power of&quot;</p>

<h3 class="Heading2"><font color="#0000A0">Vector products</font> </h3>
<h4 class="Heading2"><font color="#0000A0">Vector products</font> </h4>
<p class="program">f = cross(a,b) # cross product<br />
g = dot(a,b)&nbsp;&nbsp; # dot product<br />
h = norm(a) &nbsp;&nbsp;&nbsp;# normalized (unit) vector; a/mag(a); same as hat(a) or a.hat</p>
h = hat(a) &nbsp;&nbsp;&nbsp;&nbsp;# normalized (unit) vector a/mag(a); same as a.hat and a.norm() or norm(a)</p>
<p class="Normal"> The attributes of VPython objects can be vectors, such

as velocity or momentum.</p>

<h3 class="Heading-1"> <font color="#0000A0">III. Simple Python Programming</font></h3>

<h3 class="Heading2"><font color="#0000A0">Using the 3D Graphics Module</font></h3>
<h3><font color="#0000A0">3: Simple Python Programming</font>

</h3>
<h5 class="Heading2"><font color="#0000A0">Using the 3D Graphics Module</font></h5>

<p class="Normal"> The necessary first line of your program is created for you, and looks like this, if the current version is 3.0:</p>
<p class="program"> GlowScript 3.0 VPython</p>
<p class="Normal"> The necessary first line of a Web VPython program is created for you, and looks like this, if the current version is 3.2:</p>
<p class="program"> Web VPython 3.2</p>

<h3 class="Heading2"><font color="#0000A0">Comments</font></h3>
<h5 class="Heading2"><font color="#0000A0">Comments</font></h5>
<p class="Normal"> A comment in a Python program starts with &quot;#&quot;</p>
<p class="program"> # This line is a comment</p>

<h3 class="Heading2"><font color="#0000A0">Variables</font></h3>
<h5 class="Heading2"><font color="#0000A0">Variables</font></h5>

<p class="Normal"> Variables can be created anywhere in a Python program, simply by assigning a variable name to a value. The type of the variable is determined by the assignment statement.</p>
<p class="program"> a = 3 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# an integer<br />
b = -2.4 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# a floating-point number<br />
c = vector(0.4, 3e3, -1e1) # a vector<br />
c = vector(0.4, 3e3, -1e1) # a vector; can abbreviate to vec<br />
Earth = sphere(pos=vector(0,0,0), radius=6.4e6) # a 3D object<br />
bodies = [ship, Earth, Moon]

Expand All @@ -158,12 +160,11 @@ <h3 class="Heading2"><font color="#0000A0">Variables</font></h3>
as mass or velocity. Other objects, such as vector(), have built-in
attributes
but you cannot create additional attributes. </p>
<h3 class="Heading2"><font color="#0000A0">Exponentiation</font></h3>
<h5 class="Heading2"><font color="#0000A0">Exponentiation</font></h5>

<p class="program"> x**2 # Not x^2, which is a bit operation in Python</p>

<h3 class="Heading2"> <font color="#0000A0">Logical Tests</font></h3>
<p class="program"></p>
<h5 class="Heading2"> <font color="#0000A0">Logical Tests</font></h5>
<p class="program"> # Note the obligatory indentation here.<br />
if a == b:&nbsp;&nbsp;&nbsp;# note the double equal sign for &quot;is equal&quot;<br />
&nbsp;&nbsp;&nbsp;&nbsp;c = 5 &nbsp;&nbsp;&nbsp;# executed if a is equal to b<br />
Expand All @@ -172,7 +173,7 @@ <h3 class="Heading2"> <font color="#0000A0">Logical Tests</font></h3>
&nbsp;&nbsp;&nbsp;&nbsp;x = a+b<br />
else:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# any other case<br />
&nbsp;&nbsp;&nbsp;&nbsp;x = b/a </p>
<h3 class="Heading2"><font color="#0000A0">Logical expressions</font></h3>
<h5 class="Heading2"><font color="#0000A0">Logical expressions</font></h5>
<table border="1">
<tr>
<td rowspan="1" colspan="1"><p class="program"> ==</p></td>
Expand Down Expand Up @@ -216,7 +217,7 @@ <h3 class="Heading2"><font color="#0000A0">Logical expressions</font></h3>
</tr>
</table>

<h3 class="Heading2"><font color="#0000A0">Lists</font></h3>
<h5 class="Heading2"><font color="#0000A0">Lists</font></h5>
<p class="Normal"> A list is an ordered sequence of any kind of object. It is delimited by square brackets.</p>
<p class="program"> moons = [Io, Europa, Ganymede, Callisto]</p>
<p class="Normal"> The function &quot;arange&quot; (short for &quot;arrayrange&quot;)
Expand All @@ -228,7 +229,7 @@ <h3 class="Heading2"><font color="#0000A0">Lists</font></h3>
for i in numbers:<br>
&nbsp;&nbsp;&nbsp;&nbsp;print(i) # prints 0, 1, 2, 3, 4</p>

<h3 class="Heading2"> <font color="#0000A0">Loops</font></h3>
<h5 class="Heading2"> <font color="#0000A0">Loops</font></h5>
<p class="Normal"> The simplest loop in Python is a &quot;while&quot; loop. The loop continues as long as the specified logical expression is true (note the obligatory indentation):</p>
<p class="program"> while x &lt; 23:<br />
&nbsp;&nbsp;&nbsp;&nbsp;x = x + vx*dt</p>
Expand All @@ -252,15 +253,15 @@ <h3 class="Heading2"> <font color="#0000A0">Loops</font></h3>
<p class="program">if a == b: continue # go back to the start of the loop<br />
if a &gt; b: break &nbsp;&nbsp;&nbsp;&nbsp;# exit the loop</p>

<h3 class="Heading2"> <font color="#0000A0">Printing results</font></h3>
<h5 class="Heading2"> <font color="#0000A0">Printing results</font></h5>
<p class="Normal"> To print a number, a vector, a list, or anything else,
use the &quot;print&quot; option:</p>
<p class="program"> print(Europa.momentum)</p>
<p class="Normal"> To print a text message, enclose it in quotes:</p>
<p class="program"> print(&quot;We crashed with speed&quot;, v, &quot;m/s.&quot;)</p>
<p class="Normal"> This could also be done like this (note the initial &quot;f&quot; that makes this work):</p>
<p class="program"> print(f&quot;We crashed with speed {v} m/s.&quot;)</p>
<h3 class="Heading2"><font color="#0000A0">More Information about Python</font></h3>
<h5 class="Heading2"><font color="#0000A0">More Information about Python</font></h5>
<p class="Normal">We have summarized a small but important subset of the Python programming
language. Extensive Python information is available on the internet.</p>
<p class="Normal">&nbsp;</p>
Expand Down
Loading

0 comments on commit a0cfd87

Please sign in to comment.