Math Is Fun Forum

  Discussion about math, puzzles, games and fun.   Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ -¹ ² ³ °

You are not logged in.

#1 2007-08-31 01:40:15

luca-deltodesco
Member
Registered: 2006-05-05
Posts: 1,470

implicit function renderer c++

After my little 2d implicit function rendering application in flash, i decided this morning to make on in c++ and its just about finished (no GUI but the renderer itself)

It works on the same principle as the flash one, it splits the space up into cubes, and depending upon the function values at each vertex of the cube (inside or outside) it linearlly interpolated and produces a triangle/set of triangles to approximate the shape of the surface inside that cube building up to a full polygonal mesh. The colour is given by the partial derivitives of the surface at the points of the polygon vertices.

here is my favourite rendering so far:

http://img209.imageshack.us/my.php?image=effing1uu5.jpg
http://img168.imageshack.us/my.php?image=effing2wd9.jpg
http://img178.imageshack.us/my.php?image=effing3pl5.jpg
http://img178.imageshack.us/my.php?image=effing4ff2.jpg

The grid is from (-180,-180,-180) to (180,180,180) with cell sizes of (5,5,5) although even cell size of 15 gives a nice rendering
the total number of triangles in the mesh is  with cell size (5,5,5) : 51868

the equation of the surface is:


The Beginning Of All Things To End.
The End Of All Things To Come.

Offline

#2 2007-08-31 02:12:08

mikau
Member
Registered: 2005-08-22
Posts: 1,504

Re: implicit function renderer c++

very cool!

but this should be in coders corner, no?

did you use openGL for the renderings?


A logarithm is just a misspelled algorithm.

Offline

#3 2007-08-31 02:29:09

luca-deltodesco
Member
Registered: 2006-05-05
Posts: 1,470

Re: implicit function renderer c++

i guess it could go to coders corner, although at the same time it is sort of a 'this is cool' thing for a maths forum no?

yes im using openGL, if i had the patience i would implement my shadow mapping shaders to give it some self shadowing and proper lighting wink but i wont, thats a bit over the top for a function grapher

heres a barth sextic rendered in it:
http://img160.imageshack.us/my.php?image=effing5rb6.jpg


The Beginning Of All Things To End.
The End Of All Things To Come.

Offline

#4 2007-08-31 04:50:34

luca-deltodesco
Member
Registered: 2006-05-05
Posts: 1,470

Re: implicit function renderer c++

added some perlin noise to the colouring:
http://img234.imageshack.us/my.php?image=effing6ie7.jpg

and here ive spuced it up with some trig functions:
http://img107.imageshack.us/my.php?image=effing7yz5.jpg


The Beginning Of All Things To End.
The End Of All Things To Come.

Offline

#5 2007-09-01 05:10:10

luca-deltodesco
Member
Registered: 2006-05-05
Posts: 1,470

Re: implicit function renderer c++

it also turns out that it can actually render quaternion julia set fractals aswell although the shading is understandibly a little messed up.

http://img505.imageshack.us/my.php?image=effing8jv9.jpg

and as a wire mesh

http://img265.imageshack.us/my.php?image=effing9uf7.jpg

usually for julia sets, you iterate the function z[n+1] = z[n]^2 + c and if its magnitude goes over '2' you say it goes to infinity and not in the set.

so what i did was iterate it 10 times for this picture, and then the return value for the f(x,y,z) = 0 function, was the magnitude, minus 2 so that points that in iteration would be 'about to escape' i.e. on the edge. are treat as the surface for the grapher

Last edited by luca-deltodesco (2007-09-01 05:11:40)


The Beginning Of All Things To End.
The End Of All Things To Come.

Offline

#6 2007-09-01 10:03:28

luca-deltodesco
Member
Registered: 2006-05-05
Posts: 1,470

Re: implicit function renderer c++

i finished it up so theres no glitches anymore, its also alot more tidy and shorter.

heres a very nice set of renderings (especcialy the second one)

http://img266.imageshack.us/my.php?image =fme1cv9.jpg
http://img210.imageshack.us/my.php?image =fme2yg1.jpg
http://img441.imageshack.us/my.php?image =fme3yo1.jpg
http://img441.imageshack.us/my.php?image =fme4nt0.jpg

first one, from afar
second one, from inside of the base
third one, from inside the tunnel with the hole in the arm
fourth one, from afar with wire-frame

heres a download for the program with that rendering (note that it opens full-screen with resolution of 1280x1024)

WASD to move camera
mouse to spin camera
click to change to wire-frame
ESCAPE to exit

http://delta.110mb.com/graph.zip


The Beginning Of All Things To End.
The End Of All Things To Come.

Offline

#7 2007-09-01 10:14:28

MathsIsFun
Administrator
Registered: 2005-01-21
Posts: 7,711

Re: implicit function renderer c++

I want to scream! That is just superb.

(Now put a GUI on it and publish it!)


"The physicists defer only to mathematicians, and the mathematicians defer only to God ..."  - Leon M. Lederman

Offline

#8 2007-09-06 02:29:11

krassi_holmz
Real Member
Registered: 2005-12-02
Posts: 1,905

Re: implicit function renderer c++

oh!
That's fascinating!
after you go around it, try going inside!
It's like moving in cheese!
smile


IPBLE:  Increasing Performance By Lowering Expectations.

Offline

Board footer

Powered by FluxBB