Skip to content

Commit a31a3ac

Browse files
committed
Mostly lots of documentation updates.
1 parent 100a00f commit a31a3ac

13 files changed

+298
-193
lines changed

README.txt

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,26 @@ information about the underlying implementation.) This documentation
88
was generated from the source code using the utility pydoc (for Python
99
3).
1010

11-
physvis (c) 2019 by Rob Knop, and is available under the GPL version 3.0
11+
physvis (c) 2020 by Rob Knop, and is available under the GPL version 3.0
1212
or later; see the file COPYING for the full license.
1313

1414
REQUIREMENTS
1515

1616
physvis works only with Python 3; it will not work with Python 2.
1717

1818
physvis requires numpy (https://www.numpy.org) and PyOpenGL
19-
(http://pyopengl.sourceforge.net/). If you're on Linux, almost
20-
certainly both of these (for Python 3) are included with your
21-
distribution.
19+
(http://pyopengl.sourceforge.net/); if you want to use it with the Qt
20+
GUI library, you also need PyQT5
21+
(https://www.riverbankcomputing.com/software/pyqt/intro). If you're on
22+
Linux, almost certainly both of these (for Python 3) are included with
23+
your distribution.
2224

2325
I've used this on Linux. It has been succesfully used on Windows with
2426
Anaconda installed. You can install the needed PyOpenGL libraries with
2527

2628
conda install pyopengl
2729
conda install freeglut
30+
conda install pyqt5
2831

2932
USAGE
3033

@@ -49,5 +52,16 @@ For cut and paste purposes:
4952
grcontext.py object_collection.py physvis_observer.py physvis.py qtgrcontext.py quaternions.py rater.py visual_base.py visual_label.py
5053

5154
See doc/physvis.html for a very brief introduction to code that uses
52-
this library. See bouncing_ball.py, rotating_spring.py, and
53-
vibrating_array.py for examples.
55+
this library. In the archive there are also various example programs,
56+
in increasing order of complexity:
57+
bouncing_ball.py
58+
testfaces.py
59+
facestest.py (I'm sure there's a good reason for both this and the previous)
60+
toomanyspheres.py
61+
testcurve.py
62+
axes.py
63+
many_rotators.py
64+
rotating_spring.py
65+
testtwowin.py
66+
testtwocurves.py (Qt; run with --help to see more info)
67+
vibrating_array.py (requires scipy; run with argument "qt" to use Qt backend)

doc/grcontext.html

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,11 @@
7070
</dl>
7171
<hr>
7272
Methods defined here:<br>
73-
<dl><dt><a name="GLUTContext-__init__"><strong>__init__</strong></a>(self, width=500, height=400, title='PhysVis', *args, **kwargs)</dt><dd><tt>Initialize&nbsp;self.&nbsp;&nbsp;See&nbsp;help(type(self))&nbsp;for&nbsp;accurate&nbsp;signature.</tt></dd></dl>
73+
<dl><dt><a name="GLUTContext-__init__"><strong>__init__</strong></a>(self, width=500, height=400, title='PhysVis', *args, **kwargs)</dt><dd><tt>Parameters:<br>
74+
&nbsp;<br>
75+
width&nbsp;—&nbsp;width&nbsp;of&nbsp;the&nbsp;display&nbsp;(window&nbsp;will&nbsp;be&nbsp;this&nbsp;plus&nbsp;borders)<br>
76+
height&nbsp;—&nbsp;height&nbsp;of&nbsp;the&nbsp;display<br>
77+
title&nbsp;—&nbsp;title&nbsp;of&nbsp;the&nbsp;window</tt></dd></dl>
7478

7579
<dl><dt><a name="GLUTContext-add_idle_func"><strong>add_idle_func</strong></a>(func)</dt></dl>
7680

@@ -136,7 +140,7 @@
136140

137141
<dl><dt><a name="GLUTContext-determine_perspective_matrix"><strong>determine_perspective_matrix</strong></a>(self)</dt></dl>
138142

139-
<dl><dt><a name="GLUTContext-gl_version_info"><strong>gl_version_info</strong></a>(self)</dt></dl>
143+
<dl><dt><a name="GLUTContext-gl_version_info"><strong>gl_version_info</strong></a>(self)</dt><dd><tt>Get&nbsp;some&nbsp;perhaps-misleading&nbsp;information&nbsp;about&nbsp;the&nbsp;OpenGL&nbsp;version.</tt></dd></dl>
140144

141145
<dl><dt><a name="GLUTContext-resize2d"><strong>resize2d</strong></a>(self, width, height)</dt><dd><tt>Callback&nbsp;that&nbsp;is&nbsp;called&nbsp;when&nbsp;window&nbsp;is&nbsp;resized.</tt></dd></dl>
142146

@@ -161,20 +165,28 @@
161165
<hr>
162166
Data descriptors inherited from <a href="grcontext.html#GrContext">GrContext</a>:<br>
163167
<dl><dt><strong>background</strong></dt>
168+
<dd><tt>The&nbsp;background&nbsp;color&nbsp;of&nbsp;the&nbsp;display&nbsp;(defaults&nbsp;to&nbsp;black).</tt></dd>
164169
</dl>
165170
<dl><dt><strong>center</strong></dt>
171+
<dd><tt>The&nbsp;point&nbsp;that&nbsp;the&nbsp;camera&nbsp;looks&nbsp;at.</tt></dd>
166172
</dl>
167173
<dl><dt><strong>foreground</strong></dt>
174+
<dd><tt>The&nbsp;background&nbsp;color&nbsp;of&nbsp;the&nbsp;display&nbsp;(defaults&nbsp;to&nbsp;black).</tt></dd>
168175
</dl>
169176
<dl><dt><strong>forward</strong></dt>
177+
<dd><tt>The&nbsp;direction&nbsp;the&nbsp;camera&nbsp;is&nbsp;facing.</tt></dd>
170178
</dl>
171179
<dl><dt><strong>fov</strong></dt>
180+
<dd><tt>Field&nbsp;of&nbsp;view&nbsp;of&nbsp;the&nbsp;camrea&nbsp;in&nbsp;radians.</tt></dd>
172181
</dl>
173182
<dl><dt><strong>range</strong></dt>
183+
<dd><tt>It's&nbsp;complicated&nbsp;and&nbsp;I&nbsp;don't&nbsp;think&nbsp;I've&nbsp;done&nbsp;it&nbsp;right.</tt></dd>
174184
</dl>
175185
<dl><dt><strong>scale</strong></dt>
186+
<dd><tt>Related&nbsp;to&nbsp;range,&nbsp;and&nbsp;I&nbsp;don't&nbsp;think&nbsp;I've&nbsp;done&nbsp;it&nbsp;right.</tt></dd>
176187
</dl>
177188
<dl><dt><strong>up</strong></dt>
189+
<dd><tt>The&nbsp;camera&nbsp;will&nbsp;rotate&nbsp;about&nbsp;its&nbsp;forward&nbsp;axis&nbsp;in&nbsp;an&nbsp;attempt&nbsp;to&nbsp;make&nbsp;this&nbsp;direction&nbsp;up&nbsp;on&nbsp;the&nbsp;screen.</tt></dd>
178190
</dl>
179191
<hr>
180192
Data and other attributes inherited from <a href="grcontext.html#GrContext">GrContext</a>:<br>
@@ -261,7 +273,7 @@
261273

262274
<dl><dt><a name="GrContext-determine_perspective_matrix"><strong>determine_perspective_matrix</strong></a>(self)</dt></dl>
263275

264-
<dl><dt><a name="GrContext-gl_version_info"><strong>gl_version_info</strong></a>(self)</dt></dl>
276+
<dl><dt><a name="GrContext-gl_version_info"><strong>gl_version_info</strong></a>(self)</dt><dd><tt>Get&nbsp;some&nbsp;perhaps-misleading&nbsp;information&nbsp;about&nbsp;the&nbsp;OpenGL&nbsp;version.</tt></dd></dl>
265277

266278
<dl><dt><a name="GrContext-resize2d"><strong>resize2d</strong></a>(self, width, height)</dt><dd><tt>Callback&nbsp;that&nbsp;is&nbsp;called&nbsp;when&nbsp;window&nbsp;is&nbsp;resized.</tt></dd></dl>
267279

@@ -290,24 +302,34 @@
290302
<hr>
291303
Data descriptors defined here:<br>
292304
<dl><dt><strong>background</strong></dt>
305+
<dd><tt>The&nbsp;background&nbsp;color&nbsp;of&nbsp;the&nbsp;display&nbsp;(defaults&nbsp;to&nbsp;black).</tt></dd>
293306
</dl>
294307
<dl><dt><strong>center</strong></dt>
308+
<dd><tt>The&nbsp;point&nbsp;that&nbsp;the&nbsp;camera&nbsp;looks&nbsp;at.</tt></dd>
295309
</dl>
296310
<dl><dt><strong>foreground</strong></dt>
311+
<dd><tt>The&nbsp;background&nbsp;color&nbsp;of&nbsp;the&nbsp;display&nbsp;(defaults&nbsp;to&nbsp;black).</tt></dd>
297312
</dl>
298313
<dl><dt><strong>forward</strong></dt>
314+
<dd><tt>The&nbsp;direction&nbsp;the&nbsp;camera&nbsp;is&nbsp;facing.</tt></dd>
299315
</dl>
300316
<dl><dt><strong>fov</strong></dt>
317+
<dd><tt>Field&nbsp;of&nbsp;view&nbsp;of&nbsp;the&nbsp;camrea&nbsp;in&nbsp;radians.</tt></dd>
301318
</dl>
302319
<dl><dt><strong>height</strong></dt>
320+
<dd><tt>The&nbsp;height&nbsp;in&nbsp;pixels&nbsp;of&nbsp;the&nbsp;display.</tt></dd>
303321
</dl>
304322
<dl><dt><strong>range</strong></dt>
323+
<dd><tt>It's&nbsp;complicated&nbsp;and&nbsp;I&nbsp;don't&nbsp;think&nbsp;I've&nbsp;done&nbsp;it&nbsp;right.</tt></dd>
305324
</dl>
306325
<dl><dt><strong>scale</strong></dt>
326+
<dd><tt>Related&nbsp;to&nbsp;range,&nbsp;and&nbsp;I&nbsp;don't&nbsp;think&nbsp;I've&nbsp;done&nbsp;it&nbsp;right.</tt></dd>
307327
</dl>
308328
<dl><dt><strong>up</strong></dt>
329+
<dd><tt>The&nbsp;camera&nbsp;will&nbsp;rotate&nbsp;about&nbsp;its&nbsp;forward&nbsp;axis&nbsp;in&nbsp;an&nbsp;attempt&nbsp;to&nbsp;make&nbsp;this&nbsp;direction&nbsp;up&nbsp;on&nbsp;the&nbsp;screen.</tt></dd>
309330
</dl>
310331
<dl><dt><strong>width</strong></dt>
332+
<dd><tt>The&nbsp;width&nbsp;in&nbsp;pixels&nbsp;of&nbsp;the&nbsp;display.</tt></dd>
311333
</dl>
312334
<hr>
313335
Data and other attributes defined here:<br>

doc/physvis.html

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,15 @@
5757
&nbsp;&nbsp;<a href="#-rate">rate</a>(30)<br>
5858
&nbsp;<br>
5959
This&nbsp;does&nbsp;two&nbsp;things.&nbsp;&nbsp;First,&nbsp;it&nbsp;allows&nbsp;the&nbsp;display&nbsp;to&nbsp;update.&nbsp;&nbsp;Second,&nbsp;it&nbsp;limits&nbsp;your<br>
60-
loop&nbsp;to&nbsp;run&nbsp;no&nbsp;more&nbsp;than&nbsp;30&nbsp;times&nbsp;a&nbsp;second.&nbsp;&nbsp;(You&nbsp;can&nbsp;replace&nbsp;30&nbsp;with&nbsp;a&nbsp;different&nbsp;number,<br>
61-
of&nbsp;course.&nbsp;&nbsp;It&nbsp;doesn't&nbsp;make&nbsp;sense&nbsp;to&nbsp;do&nbsp;more&nbsp;than&nbsp;30&nbsp;or&nbsp;60&nbsp;frames&nbsp;per&nbsp;second.&nbsp;&nbsp;If&nbsp;you&nbsp;want<br>
62-
to&nbsp;do&nbsp;calculations&nbsp;more&nbsp;often&nbsp;than&nbsp;that,&nbsp;do&nbsp;multiple&nbsp;calculations&nbsp;in&nbsp;your&nbsp;loop,&nbsp;and&nbsp;only<br>
63-
update&nbsp;object&nbsp;properties&nbsp;once&nbsp;per&nbsp;loop.)&nbsp;&nbsp;Your&nbsp;loop&nbsp;may&nbsp;run&nbsp;slower&nbsp;than&nbsp;that&nbsp;if&nbsp;the<br>
64-
computer&nbsp;takes&nbsp;more&nbsp;than&nbsp;1/30&nbsp;seconds&nbsp;to&nbsp;process&nbsp;everything&nbsp;in&nbsp;your&nbsp;loop.<br>
60+
loop&nbsp;to&nbsp;run&nbsp;no&nbsp;more&nbsp;than&nbsp;30&nbsp;times&nbsp;a&nbsp;second.&nbsp;&nbsp;Your&nbsp;loop&nbsp;may&nbsp;run&nbsp;slower&nbsp;than&nbsp;that&nbsp;if&nbsp;the<br>
61+
computer&nbsp;takes&nbsp;more&nbsp;than&nbsp;1/30&nbsp;seconds&nbsp;to&nbsp;process&nbsp;everything&nbsp;in&nbsp;your&nbsp;loop.&nbsp;&nbsp;(You&nbsp;can<br>
62+
replace&nbsp;30&nbsp;with&nbsp;a&nbsp;different&nbsp;number,&nbsp;of&nbsp;course.&nbsp;&nbsp;From&nbsp;a&nbsp;human&nbsp;visual&nbsp;point&nbsp;of&nbsp;view,&nbsp;it<br>
63+
doesn't&nbsp;make&nbsp;sense&nbsp;to&nbsp;do&nbsp;more&nbsp;than&nbsp;30&nbsp;or&nbsp;60&nbsp;frames&nbsp;per&nbsp;second.&nbsp;&nbsp;If&nbsp;you&nbsp;want&nbsp;to&nbsp;do<br>
64+
calculations&nbsp;more&nbsp;often&nbsp;than&nbsp;that,&nbsp;do&nbsp;multiple&nbsp;calculations&nbsp;in&nbsp;your&nbsp;loop,&nbsp;and&nbsp;only&nbsp;update<br>
65+
object&nbsp;properties&nbsp;once&nbsp;per&nbsp;loop.&nbsp;&nbsp;What's&nbsp;more,&nbsp;your&nbsp;rate&nbsp;may&nbsp;be&nbsp;clamped&nbsp;anyway&nbsp;to<br>
66+
something&nbsp;liek&nbsp;60&nbsp;updates&nbsp;per&nbsp;second&nbsp;based&nbsp;on&nbsp;the&nbsp;graphics&nbsp;system&nbsp;framerate.&nbsp;&nbsp;See&nbsp;comments<br>
67+
in&nbsp;Rater.py&nbsp;for&nbsp;a&nbsp;description&nbsp;of&nbsp;this,&nbsp;and&nbsp;run&nbsp;"python3&nbsp;testtwocurves.py&nbsp;--help"&nbsp;for<br>
68+
options&nbsp;on&nbsp;that&nbsp;program&nbsp;to&nbsp;play&nbsp;with&nbsp;this.)<br>
6569
&nbsp;<br>
6670
The&nbsp;user&nbsp;can&nbsp;rotate&nbsp;the&nbsp;orientation&nbsp;of&nbsp;the&nbsp;display&nbsp;by&nbsp;holding&nbsp;down&nbsp;the&nbsp;right&nbsp;mouse&nbsp;button<br>
6771
and&nbsp;moving&nbsp;the&nbsp;mouse.&nbsp;&nbsp;Roll&nbsp;the&nbsp;mouse&nbsp;wheel,&nbsp;or&nbsp;hold&nbsp;down&nbsp;the&nbsp;middle&nbsp;mouse&nbsp;button&nbsp;and&nbsp;move<br>

doc/quaternions.html

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,27 @@
2727
<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
2828

2929
<tr><td bgcolor="#aa55cc"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
30-
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="numpy.html">numpy</a><br>
31-
</td><td width="25%" valign=top></td><td width="25%" valign=top></td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
30+
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="math.html">math</a><br>
31+
</td><td width="25%" valign=top><a href="numpy.html">numpy</a><br>
32+
</td><td width="25%" valign=top></td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
3233
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
3334
<tr bgcolor="#eeaa77">
3435
<td colspan=3 valign=bottom>&nbsp;<br>
3536
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
3637

3738
<tr><td bgcolor="#eeaa77"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
38-
<td width="100%"><dl><dt><a name="-quaternion_multiply"><strong>quaternion_multiply</strong></a>(p, q)</dt><dd><tt>Multiply&nbsp;a&nbsp;vector&nbsp;or&nbsp;quaternion&nbsp;p&nbsp;by&nbsp;a&nbsp;quaternion&nbsp;q.<br>
39+
<td width="100%"><dl><dt><a name="-axistrig_rotate"><strong>axistrig_rotate</strong></a>(v, axis, cosangle_2, sinangle_2)</dt><dd><tt>Rotate&nbsp;vector&nbsp;v&nbsp;about&nbsp;axis&nbsp;by&nbsp;angle&nbsp;θ,&nbsp;where&nbsp;cosangle_2=cos(θ/2)&nbsp;and&nbsp;sinangle_2=sin(θ/2)</tt></dd></dl>
40+
<dl><dt><a name="-quaternion_multiply"><strong>quaternion_multiply</strong></a>(p, q)</dt><dd><tt>Multiply&nbsp;a&nbsp;vector&nbsp;or&nbsp;quaternion&nbsp;p&nbsp;by&nbsp;a&nbsp;quaternion&nbsp;q.<br>
41+
&nbsp;<br>
42+
In&nbsp;this&nbsp;context,&nbsp;a&nbsp;quaternion&nbsp;is&nbsp;[&nbsp;sin(θ/2)*ux,&nbsp;sin(θ/2)*uy,<br>
43+
sin(θ/2)*uz,&nbsp;cos(θ/2)&nbsp;]&nbsp;where&nbsp;(ux,&nbsp;uy,&nbsp;uz)&nbsp;is&nbsp;the&nbsp;unit&nbsp;vector&nbsp;about<br>
44+
which&nbsp;to&nbsp;rotate&nbsp;and&nbsp;θ&nbsp;is&nbsp;the&nbsp;angle&nbsp;by&nbsp;which&nbsp;to&nbsp;rotate.<br>
3945
&nbsp;<br>
4046
If&nbsp;p&nbsp;is&nbsp;a&nbsp;quaternion,&nbsp;the&nbsp;returned&nbsp;quaternion&nbsp;represents&nbsp;rotation&nbsp;q&nbsp;followed&nbsp;by&nbsp;rotation&nbsp;p</tt></dd></dl>
41-
<dl><dt><a name="-quaternion_rotate"><strong>quaternion_rotate</strong></a>(p, q)</dt><dd><tt>Rotate&nbsp;vector&nbsp;p&nbsp;by&nbsp;quaternion&nbsp;q.</tt></dd></dl>
47+
<dl><dt><a name="-quaternion_rotate"><strong>quaternion_rotate</strong></a>(p, q)</dt><dd><tt>Rotate&nbsp;vector&nbsp;p&nbsp;by&nbsp;quaternion&nbsp;q.<br>
48+
&nbsp;<br>
49+
In&nbsp;this&nbsp;context,&nbsp;a&nbsp;quaternion&nbsp;is&nbsp;[&nbsp;sin(θ/2)*ux,&nbsp;sin(θ/2)*uy,<br>
50+
sin(θ/2)*uz,&nbsp;cos(θ/2)&nbsp;]&nbsp;where&nbsp;(ux,&nbsp;uy,&nbsp;uz)&nbsp;is&nbsp;the&nbsp;unit&nbsp;vector&nbsp;about<br>
51+
which&nbsp;to&nbsp;rotate&nbsp;and&nbsp;θ&nbsp;is&nbsp;the&nbsp;angle&nbsp;by&nbsp;which&nbsp;to&nbsp;rotate.</tt></dd></dl>
4252
</td></tr></table>
4353
</body></html>

0 commit comments

Comments
 (0)