You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<pclass="Normal"> <ahref="VisualIntro.html">Overview of Python & VPython<br>
16
+
</a></p>
17
+
<pclass="Normal"><ahref="https://trinket.io/matter-interactions/courses/00_welcome_to_vpython#/welcome-to-vpython/getting-started"> "Welcome to VPython" tutorial</a></p>
<h1class="Heading-1"><fontcolor="#0000A0">Math displays using LaTeX</font> - GlowScript VPython only</h1>
33
+
<h1class="Heading-1"><fontcolor="#0000A0">Math displays using LaTeX</font> - Web VPython only</h1>
34
34
</div>
35
35
<div>
36
-
<pclass="Normal">In GlowScript VPython (but not currently in VPython 7) you can display complex mathematical expressions expressed in the widely used math editing format, <ahref="http://www.latex-project.org/" target="_blank">LaTeX</a>. Here is <strong><ahref="https://www.glowscript.org/#/user/GlowScriptDemos/folder/Examples/program/LaTexMathDisplay" target="_blank">an example</a></strong>. The LaTeX capability is provided by <ahref="http://www.mathjax.org/" target="_blank">MathJax</a>, which is imported by GlowScript. For example, consider this mathematical display:</p>
36
+
<pclass="Normal">In Web VPython (but not currently in VPython 7) you can display complex mathematical expressions expressed in the widely used math editing format, <ahref="http://www.latex-project.org/" target="_blank">LaTeX</a>. Here is <strong><ahref="https://www.glowscript.org/#/user/GlowScriptDemos/folder/Examples/program/LaTexMathDisplay" target="_blank">an example</a></strong>. The LaTeX capability is provided by <ahref="http://www.mathjax.org/" target="_blank">MathJax</a>, which is imported by Web VPython. For example, consider this mathematical display:</p>
<pclass="Normal"> <ahref="VisualIntro.html">Overview of Python & VPython<br>
16
+
</a></p>
17
+
<pclass="Normal"><ahref="https://trinket.io/matter-interactions/courses/00_welcome_to_vpython#/welcome-to-vpython/getting-started"> "Welcome to VPython" tutorial</a></p>
<pclass="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 "GlowScript 3.0 VPython". Start typing your program on the second line. Click "Run this program" to try out your program.</p>
<pclass="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 "Web VPython 3.2". Start typing your program on the second line. Click "Run this program" to try out your program.</p>
<pclass="Normal"> When using VPython the canvas shows objects in 3D.</p>
42
43
<pclass="Normal"> (0,0,0) is in the center of the canvas<imgsrc="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>
43
44
<pclass="Normal"> x, y, and z are measured in whatever units you choose;
<pclass="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>
<pclass="Normal">If you type or copy the following simple program into the program editor and run it (click "Run this program" or press Ctrl-1 or Ctrl-2), you will see
58
59
a canvas conatining a red box and a green sphere, as shown in the figure. </p>
<pclass="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>
147
149
<pclass="program"> a = 3 # an integer<br/>
148
150
b = -2.4 # a floating-point number<br/>
149
-
c = vector(0.4, 3e3, -1e1) # a vector<br/>
151
+
c = vector(0.4, 3e3, -1e1) # a vector; can abbreviate to vec<br/>
150
152
Earth = sphere(pos=vector(0,0,0), radius=6.4e6) # a 3D object<br/>
<pclass="Normal"> The simplest loop in Python is a "while" loop. The loop continues as long as the specified logical expression is true (note the obligatory indentation):</p>
0 commit comments