Physics, Art, and Programming Ben Hoffman

Ben Hoffman's Facequation.......................................................................................

Now we're going to look at how some physics ideas like vector addition and flux can help us with graphics programming. The above image is what we will be talking about. It is actually a graph of a three dimensional solid that I designed. It is a function (y in terms of x and z) that goes something like this:

 

Y = ((-(t-50)/2-53)/((((t-50)/100)^8)+1))*(-(((z^2)/50)-80)/(((z/50)^8)+1) )*.01 + (((t^2)/2800)-150)/(((t/500)^18)+1) * (-(((z^2)/800)-150)/(((z/200)^10)+1))/150 +((((t-270)^2)/40)-30)/(((((t-270)-17)/17)^1006)+1) * ((-4*1.5^(3.8*sin((z-90)/19))-30) / (((z/100)^8)+1)) /-30 + ((-(t-270)/2)-30)/(((((t-270)+30)/30)^10006)+1) * ((-4*1.5^(3.8*sin((z-90)/19))-30) / (((z/100)^8)+1)) /-30 + ((((t-340)^2)/40)-30)/(((((t-340)+17)/17)^1006)+1) * -(((z^2)/330)-35)/(((z/80)^8)+1)/35 + ((t-340)/2)-30)/(((((t-340)-30)/30)^10006)+1) * -(((z^2)/330)-35)/(((z/80)^8)+1)/35 + -((((t-371)^2)/80)-10)/((((t-371)/28)^1006)+1) * -(((z^2)/330)-35)/(((z/80)^8)+1)/35 + -((((t+60)^2)/150)-40)/((((t+60)/60)^8)+1) * -((((z+87)^2)/180)-30)/((((z+87)/60)^8)+1) + -((((z-87)^2)/180)-30)/((((z-87)/60)^8)+1) /30 + ((t+60)/2)/((((t+60)/60)^6)+1) * -((((z+87)^2)/180)-30)/((((z+87)/60)^8)+1) + -((((z-87)^2)/180)-30)/((((z-87)/60)^8)+1) /30 + (((((t+45)^2)/40)-40)/((((t+45)/40)^200)+1) )* -(((((z-87)^2)/40)-40)/((((z-87)/40)^200)+1) + ((((z+87)^2)/40)-40)/((((z+87)/40)^200)+1))/40 + ((-(t-450)/1.5)-34)/((((t-450)/40)^4)+1) * -((((z^2)/125)-200)/(((z/130)^10)+1))*.4/200 + (((((t+350)^2)/1000)-10)/((((t+350)/80)^10)+1)) *(-(((z^2)/800)-150)/(((z/200)^10)+1))/150


(x is a linear function of t)

 

This looks pretty bad, but it is actually not nearly as complicated as it looks at first glance. It is set up so that the xy plane is the screen and z is in and out of the screen. What you are seeing has been decorated with a different graphic editing program. The way that it was generated is actually similar to the mathematics of double or triple integrals for the volume of solids. The picture is drawn one slice at a time.

Each slice is drawn according to y in terms of x while holding z at a constant value. The actual rendering looks something like this:

How it was built:

The face is made up of these y in terms of x and z solids all added on top of one another. For example, the nose could be a stand-alone solid all by itself. The way that I created the individual solids was by generating an xy curve that looks like the figure at its maximum y values:

These curves are usually made up of sections of curves. This nose is made up of a section of a line equation. It was actually pretty complicated to get just one section of any curve. I figured that I could use the concept that you see with higher even powered single component polynomials. With a function like y=x^20 , you have astronomical values everywhere but between -1 and 1. Invert the idea, do a little tweaking with the range and you can grab any section of any curve. To turn this idea into a three-dimensional one, one can use similar methods to create a yz curve that represents the solid from the top down. When one looks down at the nose they might see something like this yz curve:

Then you turn this curve into what I like to call a unit function. This means that the max value of this yz curve is now one. If you then multiply the xy function with yz function you end up with a solid that looks like the first picture from the side and the second picture from the top and bottom:

 

There were two problems that I encountered that only physics concepts could help me with. Both of these problems were related to the three dimensional displaying of the solid in a two dimension plain. The first problem was clear before I was even done creating the face. Once you've created a three-dimensional solid the first thing that comes to mind is that there must be a mathematical way of viewing or displaying the solid at any angle (trust me). I started by assigning three new angle variables (one for each axis). I then thought that all I would have to do is figure out how to rotate the solid about each one of the axis and that I could use combinations of the different axis rotations to achieve any angle. I watched the face rotate around the y-axis in my head and thought that all you have to do is slowly smash the curves horizontally and eventually invert them and stretch them back out:

This method worked on all of the axis individually but when combine the smashing alters the solid in form. You can easily smash your solid into nothing if the right angle is chosen. At this point I was stuck pulling vary hard on my hair for two weeks. I finally figured out a way that very simple physics could help me. Instead of messing with the entire curves, I thought of each plotted point as displacement vector on a rotating object. I used the physics vector methods to acquire a radius and angle for each point around a given axis. Then I added the desired amount to that angle and (depending on which axis I was rotating around) I multiplied the radius by the sin or cosine accordingly. This method is the right way to rotate solids because it resembles actual rotational physics. Using this method I could achieve any angle and before long I was rendering video clips of the facequation rotating on all three axis at once:

Due to my limited knowledge of web authoring, I can't display these videos on this page but those who want some quicktime videos of this rotation can e-mail me at benjimon333@hotmail.com.

 

The second problem had to do with the fact that if the drawing were to be rotated about the "x-axis" 90 degrees, one would only see a set of strait lines.

This is because the rendering of the face is done in plain slices that are all parallel. But even if you saw a face made of parallel slices, you would see more than strait lines. Towards the outer edge of the face you would be able to see more of the side of the slices. This is because you are seeing those slices at a different angle. It was at about the time that I had this problem time that I was relearning about electric flux in class. I finally recognized that you can treat vision lines field lines. The amount of a particular object (a plain for example) that you see depends on how many vision field lines go through that object. Lines through an object is the same thing as flux! This means (for plain slices especially) that the amount of an object that you see is directly related to the angle between the vision field lines an the surface of the object. We can take this effect into account by calculating that angle and multiplying the depth of each plain (the y value at this point) by the sin of that angle. The result of this multiplication would be the variance to the left or right of the original strait line that the angle between the field lines brought about.

Physics helped us after all!

Get me out'a here!