Skip to content

Commit 4bf74cc

Browse files
committed
Update extrusion documentation
1 parent 922fa43 commit 4bf74cc

File tree

6 files changed

+112
-11
lines changed

6 files changed

+112
-11
lines changed

docs/GlowScriptDocs/extrusion.html

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2+
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/template.dwt" codeOutsideHTMLIsLocked="false" -->
3+
<head>
4+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5+
<!-- InstanceBeginEditable name="doctitle" -->
6+
<title>compound</title>
7+
<!-- InstanceEndEditable -->
8+
<!-- InstanceBeginEditable name="head" -->
9+
<link href="VisualRef.css" rel="stylesheet" type="text/css" />
10+
<style type="text/css">
11+
<!--
12+
.style1 {font-size: x-large}
13+
.style2 {font-size: xx-large}
14+
-->
15+
</style>
16+
<!-- InstanceEndEditable -->
17+
<link href="VisualRef.css" rel="stylesheet" type="text/css" />
18+
</head>
19+
20+
<body>
21+
<table width="230" height="30" border="0">
22+
<tr>
23+
<td width="66"><a name="top" id="top"></a><a href="index.html"><strong>Home</strong></a></td>
24+
<td width="154"><span class="Normal"><a href="primitives.html"><strong>Pictures</strong></a> of 3D objects</span></td>
25+
</tr>
26+
</table>
27+
<table width="438" height="30" border="0">
28+
<tr>
29+
<td width="151"><select id="menu1" onchange="jumpMenu(this)">
30+
</select></td>
31+
<td width="163"><select id="menu2" onchange="jumpMenu(this)">
32+
</select></td>
33+
<td width="110"><select id="menu3" onchange="jumpMenu(this)">
34+
</select></td>
35+
</tr>
36+
</table>
37+
<table width="454" border="0" cellpadding="0" cellspacing="0">
38+
<!--DWLayoutDefaultTable-->
39+
<tr>
40+
<td width="454" rowspan="2" valign="top"><!-- InstanceBeginEditable name="content" -->
41+
<div>
42+
<table width="100%" height="83" border="1">
43+
<tr>
44+
<td width="67%" height="77"><div align="center"><span class="style1 style2"><font color="#0000A0">extrusion</font></span></div></td>
45+
<td width="33%"><div align="center"><a href="arrow.html"></a><img src="images/extrusion.PNG" width="147" height="149" alt="extrusion" /></div></td>
46+
</tr>
47+
</table>
48+
</div>
49+
<div>
50+
<p class="Normal">The extrusion object extrudes a 2D shape along a path. Here is an <strong><a href="http://www.glowscript.org/#/user/GlowScriptDemos/folder/Examples/program/Extrusions" target="_blank">example</a></strong>.</p>
51+
<p class="Normal">The GlowScript extrusion object is currently more limited than the classic VPython extrusion object. Here is the minimal syntax:</p>
52+
<p align="center" class="program">ex = extrusion(pos=..., shape=...)</p>
53+
<p class="Normal"> The <span class="attribute">pos</span> attribute is a list of points like the <span class="attribute">pos</span> attribute of a curve object. The <span class="attribute">shape</span> attribute is a list of x-y pairs describing the perimeter of a 2D surface, such as<span class="program">[ [2,0], [0,4], [-2,0], [2,0] ]</span>. </p>
54+
<p class="Normal"><strong><font color="#0000a0">The three steps to make an extrusion</font></strong></p>
55+
<p class="Normal"><strong>1)</strong> Create a 2D shape, either by giving a list of points or by choosing a shape from a supplied library of common shapes. Here are two examples. The first creates a triangle by providing 3 points to the Polygon function. The second creates a circular shape from a library of shapes, and the third creates a rectangular shape (it is intended to provide a larger variety of shapes in the future.)</p>
56+
<p class="program">tri = [ [2,0], [0,4], [-2,0], [2,0] ]</p>
57+
<p class="program">circ = shapes.circle(radius=0.8)</p>
58+
<p class="program">rect = shapes.rectangle(width=0.2, <br />
59+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; height=0.4)<br />
60+
</p>
61+
<p class="Normal">Currently a shape must be closed. That is, the last point must be the same as the first point.</p>
62+
<p class="Normal"><strong>2)</strong> Create a path along which to extrude your shape (just like the <span class="attribute">pos</span> attribute of a curve object), either by giving a list of points or by choosing a path from a supplied library of common paths. Here are two examples. The first is a triangular path. The second chooses a circular path in the xz plane, and the third chooses a rectangular path in the xz plane.</p>
63+
<p class="program">tripath = [ vec(1,0,0), vec(0,0,-2), <br />
64+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vec(-1,0,0], vec(1,0,0) ]</p>
65+
<p class="program">circpath = paths.circle(radius=3)</p>
66+
<p class="program">rectpath = paths.rectangle(width=4, <br />
67+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; height=2)<br />
68+
</p>
69+
<p class="Normal">Currently a path must be closed. That is, the last point must be the same as the first point.</p>
70+
<p class="Normal"><strong>3)</strong> Create an extrusion object to extrude your shape along your path. For example, using paths and shapes defined above,</p>
71+
<p class="program">extrusion(pos=circpath, shape=rect) </p>
72+
<div>
73+
<div>
74+
<div>
75+
<div>
76+
<div>
77+
<div></div>
78+
</div>
79+
<p class="Normal"><strong><font color="#0000a0">Path direction</font></strong></p>
80+
<p class="Normal">The paths in the paths library all go counterclockwise in the xz plane, as seen from above. That is, if starting from a position on the x axis, they head in the -z direction and bend toward the left. If your shape has something sticking out on the right, it will be on the outer side of the extrusion, whereas something sticking out on the left will be on the inner side of the extrusion.</p>
81+
<div>
82+
<div></div>
83+
</div>
84+
<p class="Normal"><strong><font color="#0000a0">Dynamic change of attributes</font></strong></p>
85+
<div>
86+
<div></div>
87+
</div>
88+
</div>
89+
</div>
90+
<p class="Normal">The extrusion object is rendered quite rapidly, so unusual effects are possible. An extrusion object is treated like a compound object, and you can dynamically change its pos (a vector), axis, size, color, and up attributes, as with other objects.</p>
91+
<p class="Normal"><strong><font color="#0000a0">How the extrusion machinery works</font></strong></p>
92+
<p class="Normal">At every point along the <span class="attribute">pos</span> path this point plus the preceding and following points define a plane. A 2D plane is established perpendicular to the tangent to the circle at this point. The 2D shape is drawn in this 2D plane. A shape should be positioned so that its center is approximately at the location of the <span class="attribute">pos</span> locations. If you offset the shape far from the path, you may get odd results, because there is enhanced danger of two adjacent drawing planes intersecting each other. Also, making sharp turns of wide extrusions may lead to one segment overlapping another. </p>
93+
<p class="Normal">If the bending angle from one point to the next is large, the fitted circle is abandoned, and the orientation of the 2D plane is determined from the direction from the previous point to the current point and the direction from the current point to the next point, giving a mitered joint. The bending angle is considered to be large if its cosine if greater than 0.95 (an angle of about 18 degrees). </p>
94+
</div>
95+
<div></div>
96+
</div>
97+
<!-- InstanceEndEditable --></td>
98+
</tr>
99+
</table>
100+
<p><a href="#top"><strong>Top of page</strong></a></p>
101+
</body>
102+
<script type="text/javascript" language="javascript" src="navigation.js"></script>
103+
<!-- InstanceEnd --></html>
62.9 KB
Loading

docs/VPythonDocs/extrusion.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,12 @@
4949

5050
<table width="100%" border="1">
5151
<tr>
52-
<td width="99%"><div align="center"><span class="style1 style2"><font color="#0000A0">extrusion</font></span></div></td>
53-
<td width="1%"><div align="center"><a href="arrow.html"></a></div></td>
52+
<td width="77%"><div align="center"><span class="style1 style2"><font color="#0000A0">extrusion</font></span></div></td>
53+
<td width="23%"><div align="center"><a href="arrow.html"></a><img src="images/extrusion.PNG" width="147" height="149" alt="extrusion" /></div></td>
5454
</tr>
5555
</table>
56-
<p class="Normal">The extrusion object extrudes a 2D shape along a path. The GlowScript extrusion object is currently more limited than the classic VPython extrusion object. Here is the minimal syntax:</p>
56+
<p class="Normal">The extrusion object extrudes a 2D shape along a path. Here is an <strong><a href="http://www.glowscript.org/#/user/GlowScriptDemos/folder/Examples/program/Extrusions" target="_blank">example</a></strong>.</p>
57+
<p class="Normal">The GlowScript extrusion object is currently more limited than the classic VPython extrusion object. Here is the minimal syntax:</p>
5758
<p align="center" class="program">ex = extrusion(pos=..., shape=...)</p>
5859
<p class="Normal"> The <span class="attribute">pos</span> attribute is a list of points like the <span class="attribute">pos</span> attribute of a curve object. The <span class="attribute">shape</span> attribute is a list of x-y pairs describing the perimeter of a 2D surface, such as<span class="program">[ [2,0], [0,4], [-2,0], [2,0] ]</span>. </p>
5960
<p class="Normal"><strong><font color="#0000a0">The three steps to make an extrusion</font></strong></p>

docs/VPythonDocs/images/extrusion.PNG

62.9 KB
Loading

docs/VPythonDocs/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,12 @@
158158
<p class="Normal">In GlowScript you can use the shorthand &quot;vec&quot; for &quot;vector&quot;, and it is intended to have classic VPython also allow either form. If you wish to use a GlowScript program containing &quot;vec&quot; in the classic VPython environment, just add the statement &quot;vec = vector&quot; at the start of the program.</p>
159159
<p class="Normal">In addition to classic VPython and this new VPython in the GlowScript browser environment, a third way to run a VPython program is in an <strong><a href="http://ipython.org/notebook.html" target="_blank">IPython notebook</a></strong>, in a browser, thanks to the <strong><a href="https://pypi.python.org/pypi/IVisual/" target="_blank">ivisual</a></strong> module created by John Coady.</p>
160160
<p class="Normal"><span class="style1">Limitations</span></p>
161-
<p class="Normal">A few VPython objects are not currently available in GlowScript: convex, extrusion (and the paths and shapes libraries), faces, frame, and the 3D text object. The GlowScript objects <a href="../GlowScriptDocs/vector.html" target="_blank">vertex</a>, <a href="../GlowScriptDocs/triangle.html" target="_blank">triangle</a>, and <a href="../GlowScriptDocs/triangle.html" target="_blank">quad</a> represent a more powerful alternative to faces and are candidates for implementing in classic VPython. Many applications of frame can be handled with the GlowScript <a href="../GlowScriptDocs/compound.html" target="_blank">compound</a> object.</p>
161+
<p class="Normal">A few VPython objects are not currently available in GlowScript: convex, faces, frame, and the 3D text object. The GlowScript objects <a href="../GlowScriptDocs/vector.html" target="_blank">vertex</a>, <a href="../GlowScriptDocs/triangle.html" target="_blank">triangle</a>, and <a href="../GlowScriptDocs/triangle.html" target="_blank">quad</a> represent a more powerful alternative to faces and are candidates for implementing in classic VPython. Many applications of frame can be handled with the GlowScript <a href="../GlowScriptDocs/compound.html" target="_blank">compound</a> object. The extrusion object (and the paths and shapes libraries) currently has many fewer features than the classic version.</p>
162162
<p class="Normal">One way to deal with differences is to check the elements of the &quot;version&quot; variable that is available in both classic VPython and the GlowScript version and do different things in the different environments:</p>
163163
<p class="program">Classic VPython: &nbsp;&nbsp;&nbsp;version is ['X.Y', 'release']<br />
164164
GlowScript VPython: version is ['X.Y', 'glowscript']
165165
</p>
166-
<p class="Normal">The <a href="../GlowScriptDocs/curve.html">curve</a> and <a href="points.html">points</a> objects are slightly different in the GlowScript environment, but with a little care it is possible to use these objects in such a way that they will also work in classic VPython. Note that in GlowScript the list of points in a curve object is not a numpy array, so that a loop is required to change all of the points.</p>
166+
<p class="Normal">The <a href="../GlowScriptDocs/curve.html">curve</a> and <a href="points.html">points</a> objects are slightly different in the GlowScript environment, but with a little care it is possible to use these objects in such a way that they will also work in classic VPython. Note that in GlowScript the list of points in a curve object is not a numpy array, so that a loop is required to change all of the points. However, GlowScript programs compile to JavaScript, whose loops are much faster than classic Python loops.</p>
167167
<p class="Normal">To handle <a href="mouse.html"><strong>mouse events</strong></a> one cannot use scene.getevent() but must use scene.bind(), which is available both in VPython 6 and in GlowScript. Also available are scene.pause() and scene.waitfor('click') and related options.</p>
168168
<p class="Normal">It is possible in the GlowScript environment to place <strong><a href="../GlowScriptDocs/controls.html" target="_blank">widgets</a></strong> such as buttons or sliders on the web browser page, but the mechanism is that of HTML and jQuery, not the wxPython component of classic VPython. Currently there isn't an easy way to display a button or slider in a way that will work both in the classic VPython environment and in the GlowScript environment. </p>
169169
<p class="Normal">It is not possible to import arbitrary Python modules such as numpy, and any VPython program that uses numpy will have to be modifed. However, loops are fast in the JavaScript language to which GlowScript programs compile, so if you are using numpy solely for the speed of array manipulation, you may be able to replace a numpy calculation easily and efficiently with a loop.</p>

docs/VPythonDocs/primitives.html

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ <h1 class="Heading-1"><font color="#0000A0">The VPython 3D Object</font>s
7878
<td align="center"><span class="Normal"><a href="ellipsoid.html">ellipsoid<br />
7979
<img src="images/ellipsoid.jpg" alt="ellipsoid" width="130" height="127" /></a></span></td>
8080
<td align="center"><span class="Normal"><a href="extrusion.html">extrusion<br />
81-
<img src="images/extrusion.jpg" width="153" height="127" alt="extrusion" /></a><a href="helix.html"></a></span></td>
81+
<img src="images/extrusion.PNG" width="147" height="149" alt="extrusion" /></a><a href="helix.html"></a></span></td>
8282
<td align="center"><span class="Normal"><a href="faces.html">faces<br />
8383
<img src="images/faces.jpg" alt="faces" width="131" height="127" /></a><a href="helix.html"></a></span></td>
8484
</tr>
@@ -105,9 +105,7 @@ <h1 class="Heading-1"><font color="#0000A0">The VPython 3D Object</font>s
105105
<td align="center"><p align="center"><a href="frame.html">frame</a></p>
106106
<p align="center"><a href="frame.html"><span class="style3">Group
107107
objects together</span></a></p></td>
108-
<td><p align="center">For extrusions:</p>
109-
<p align="center"><a href="shapes.html">The shapes library</a></p>
110-
<p align="center"><a href="paths.html">The paths library</a></p></td>
108+
<td><p align="center">&nbsp;</p></td>
111109
</tr>
112110
</table>
113111
<table width="595" height="209" border="1">
@@ -126,8 +124,7 @@ <h1 class="Heading-1"><font color="#0000A0">The VPython 3D Object</font>s
126124
<tr>
127125
<td><div align="center">
128126
<a href="controls.html">controls<br />
129-
</a><a href="controls.html"><img src="images/widgets.jpg" alt="controls" width="462" height="227" /></a>
130-
</div></td>
127+
</a><a href="controls.html"><img src="images/gswidgets.png" alt="controls" width="244" height="281" /></a></div></td>
131128
</tr>
132129
<tr>
133130
<td><div align="center"><a href="files.html">get_file and save_file<br />

0 commit comments

Comments
 (0)