papervision3D - PQ torus
demo, code, actionscript, flex, flash, papervision3D, mxml
here we go again, another papervision3D demo featuring math permeated lines. this time im working with a classic piece of code known as the PQ torus. the vague idea is that you have 2 numbers (P + Q) that are used in the algorithm to define the knot. in general, given P + Q mutually prime, the line wraps meridionally around the torus P times and wraps the longitudinally around it Q times. i was having some trouble grasping exactly how this was going to be achieved, until i read this article on blackpawn’s website. he really breaks down the algo to a very simplistic level...
r = .5 * (2 + sin(Q * Φ))x = r * cos(P * Φ)y = r * cos(Q * Φ)z = r * sin(P * Φ)
simple right? lol.
so Φ (or phi in my code) is basically a variable that is definded by change. in this case, im simply incrementing phi + .02 every frame. this seeds the math and gives you the cool visual effect.
anyway, after getting a handle on the math, writing the demo code was a snap. i took the existing code i wrote from the 3D object tracer and the lorenz attractor and combined them. (i also found + fixed an error for computing the line gradient color) i started out by allowing the users to only select values for PQ and that actually made sense.


but after some experimentation i found that using some unorthodox values for P+Q could net some very interesting results. take a look at some of these...




click here to view the demo
click here for the source code




the next step is an important one ((and the one i always forget)) we need to give our 3D object a uvw mapping. still under the modifiers tab, select "UVW Mapping" from the dropdown list. and under the parameters panel make sure its mapping mode is set to "Planar". i was having all kinds of trouble exporting 3D objects that were based on points only.
now its time to export our 3D logo, click on the tools tab and select max script, then run the 










