Math Functions 00 (alt)

Published 2012-08-01
NERD POWERS ACTIVATE!!

Hello you guys,

Yeah I have fav mathematical functions. Who'd've thunk it.

This video is both a test bed and a short presentation.

A test bed because I've used a variety of software to produce this. Some of the programs I've used I've never used before so I hope this turned out okay.

The slideshow was created through one of my own programs that turns an xml like file into a slideshow.
The audio was recorded and edited in Audacity. I filtered the noise and truncated silent bits at a -35 db setting I think. I manually removed a lot of "ehh" sounds
The slideshow was put together in WLMM. Next time I may use virtual dub instead. If anyone knows some good freeware out there, please let me know. WLMM sucks dick.

I've used Pov-Ray for the images and I've just now remembered that I didn't include the source code or even screen shots in this video, only the rendered results. Meh. Also, I'm pretty good with Pov-Ray so no problems there.

Now, about the content.

I've put in a few functions, namely:
- Radial
- Angular
- Spiral
- Exponential
- Bulge
- Cellshader

The radial function is simply the distance from the origin.
The angular function is the angle with right being an angle of 0° or 360° and counter clockwise being the positive direction.
The spiral function combines the previous functions by using them as the variable for a scaled cosine.
The exponential function is 1/(1+exp(s*(x-p))). Which is approximately 0 or 1 at every value for x save for a range surrounding x=p.
The bulge is the above function multiplied by itself with a shift of 0.5 in both the positive and the negative direction. As variable it takes the radius, making it circular.

Cellshading is just another way of rendering shadows. It's not realistic and makes for cartoonish effects. It's kinda different in pov-ray because pov-ray doesn't work with triangle meshes. It's an implicit function that determines the colour of the shade.
This cellshader allows for textures, transparency and highlight effects to be used as well.
One of the best features of this function is that instead of rendering a shadow or light patches on a shape, I can add noise in those areas. So if I have a lightsource directly above a sphere and tell pov-ray that the greater the angle the greater the amount of noise that should be added to the shape must be, I can create balls of dirt or rock that have been eroded on the top side and are more raw on the bottom. I've used this feature in my update video for the floating islands.
Not only this, but I can use this feature iteratively. I can repeat the process for the new shape. Basically I can repeat this operation for quite a few steps:
shape_00 = f(x,y,z)
shape_(n+1) = shape_(n) + noise(shape_(n))
Where the noise function takes the previous shape as a parameter.
There are other ways of cellshading but those use triangle meshes.

All functions are implicit functions. Which means that they're of the form f(x,y,z) = 0. A unit sphere is therefore x*x+y*y+z*z - 1 = 0.

Here's the relevant source code for the functions. It's in pov-ray code.
Youtube prohibits the use of less than and greater than symbols, along with the squigle brackets. So the following functions are to be pasted in pov-ray as such:
#declare NAME = function(PARAMETERS) LEFTSQUIGLY DEFINITION RIGHTSQUIGLY ;
Where the squiglies are actual squigly bracket symbols and name, parameters and definition are as in the code, or name em yourself.

#declare fr = function(x,y,z) sqrt(x*x+z*z)
#declare fa = function(x,y,z) ((x less_than 0)*pi+atan(z/x))/(2*pi)
#declare fs = function(x,y,z,f) (1+cos(f*2*pi*(fa(x,y,z)+fr(x,y,z))))/2
#declare fe = function(x,s,p) 1/(1+exp(-s*(x-p)))
#declare fhat = function(x,y,z,sc,tr) fe(fr(x,y,z),sc,-tr)*fe(-fr(x,y,z),sc,-tr)/fe(0,sc,-tr)

#declare f = function(x,y,z) x*x+y*y+z*z-1+fs(x,y,z,5)*fhat(x,y,z,10,0.5)*(1-fhat(x,y,z,20,0.05))/4
#declare dx = function(x,y,z,da) da*(f(x+1/(2*da),y,z)-f(x-1/(2*da),y,z))
#declare dy = function(x,y,z,da) da*(f(x,y+1/(2*da),z)-f(x,y-1/(2*da),z))
#declare dz = function(x,y,z,da) da*(f(x,y,z+1/(2*da))-f(x,y,z-1/(2*da)))

#declare rang = function(ux,uy,uz,vx,vy,vz) acos((ux*vx+uy*vy+uz*vz)/(sqrt(ux*ux+uy*uy+uz*uz)*sqrt(vx*vx+vy*vy+vz*vz)))/pi
#declare shader = function(x,y,z,acc) rang(dx(x,y,z,acc),dy(x,y,z,acc),dz(x,y,z,acc),dx(x,y,z,acc)-Lx,dy(x,y,z,acc)-Ly­,dz(x,y,z,acc)-Lz)

#declare acc = 1000;
#declare f_iso0 = functionf(x,y,z);
#declare f_iso = function f_iso0(x,y,z)+(1-((shader(x,y,z,acc)*(shader(x,y,z,acc) greater_than 0.5)-0.5)/0.5))*(0.25*f_granite(x,y,z));

All Comments (1)