Logo by MandelBRO - Contribute your own Logo!

END OF AN ERA, FRACTALFORUMS.COM IS CONTINUED ON FRACTALFORUMS.ORG

it was a great time but no longer maintainable by c.Kleinhuis contact him for any data retrieval,
thanks and see you perhaps in 10 years again

this forum will stay online for reference
News: Check out the originating "3d Mandelbulb" thread here
 
*
Welcome, Guest. Please login or register. March 29, 2024, 11:22:58 AM


Login with username, password and session length


The All New FractalForums is now in Public Beta Testing! Visit FractalForums.org and check it out!


Pages: 1 2 [3]   Go Down
  Print  
Share this topic on DiggShare this topic on FacebookShare this topic on GoogleShare this topic on RedditShare this topic on StumbleUponShare this topic on Twitter
Author Topic: mini supercomputer  (Read 15435 times)
0 Members and 1 Guest are viewing this topic.
David Makin
Global Moderator
Fractal Senior
******
Posts: 2286



Makin' Magic Fractals
WWW
« Reply #30 on: June 14, 2008, 04:21:08 PM »

Hi,

I thought that was transparent !!

However there are a couple of differences from Hart's basic method:

1. It allows for RIFS - that's why the code to find the next transform is looking up in an array.

2. It allows for depth restrictions on transforms - that's why there's a look up in an array to find if a given transform is allowed at a given depth.

Here's some pseudo-code, I think I've got it correct. Hope it helps - the only bit that I'm hoping I've got correct is the loop to go to the next transform at the current depth and if we've done them all then to go up a depth.

Here's the pseudo-code for a single viewing ray:

calculate the base point for the ray
calculate the normalised direction vector for the ray
get the front clip (distance along ray from base point)
get the back clip offset (ditto)
set the "found" distance to a big value

if we've hit the bounding sphere

  store base point for depth 0
  store direction vectors for depth 0
  set current transform to first transform
  (normally number of transforms - 1)
  set scale at depth 0 to 1
  set depth to 0

  while depth>=0

    store current transform as transform for this depth
    current scale = scale at this depth*scale for current transform
    increment depth
    transform base point and direction vector storing values as "current" and for the new depth
    set flag to false (=="goto next transform at current depth"
    store current scale as scale for new depth

    if we're within the bailout distance

      if nearest intersection with sphere is <= distance to back clip and farthest intersection with sphere is >= front clip

        if reached max depth or (depth>min depth and reached minscale)

          if new nearest distance<found distance

            set found distance and back clip to new distance
            store any colouring information

          else

            current transform = first transform (normally number of transforms - 1)
            set flag to true (=="goto next depth" i.e. NOT "goto next transform at current depth")

          endif

        endif (reached max depth etc)

      endif (intersection with sphere within scan)

    endif (within bailout distance)

    if flag false (== "goto next transform at current depth")

      depth = depth - 1
      current transform = transform[depth]
      while flag==false

        current transform = current transform - 1
        if current transform<0

          depth = depth - 1
          if depth<0

            f = true

          else

            current transform = transform[depth]

          endif

        else

          f = true

        endif

      endwhile

      if depth>=0

        set current base point and direction vectors to values from depth

      endif

    endif

  endwhile (depth>=0)

  if found distance<big value (set at start)

    point = base point + direction vector * found

  endif
Logged

The meaning and purpose of life is to give life purpose and meaning.

http://www.fractalgallery.co.uk/
"Makin' Magic Music" on Jango
David Makin
Global Moderator
Fractal Senior
******
Posts: 2286



Makin' Magic Fractals
WWW
« Reply #31 on: June 14, 2008, 06:55:00 PM »

Also (fairly important) the initial direction vector of the viewing ray (dx,dy,dz) is normalised.

of course, but it seems you forgot about that:

Code:
; Now test if we're within the bailout distance
        if (t9 = gdist - x1*x1 - y1*y1 - z1*z1 \
                 + (x2=1.0/(dx*dx+dy*dy+dz*dz))*(t11=x1*dx+y1*dy+z1*dz)^2)>=0.0

No I didn't forget - the transforms scale the direction vectors.
For transforms that have uniform scaling (x,y,z) and no skewing/shearing etc. - such as those for the Menger Sponge - the calculations can be simplified to avoid the recalculation of inverse of the scale of the normal since the value will be the same as the overall contractive scale (that's why the routine still uses the contractive scale values).
« Last Edit: June 14, 2008, 07:08:49 PM by David Makin » Logged

The meaning and purpose of life is to give life purpose and meaning.

http://www.fractalgallery.co.uk/
"Makin' Magic Music" on Jango
lycium
Fractal Supremo
*****
Posts: 1158



WWW
« Reply #32 on: June 15, 2008, 11:08:47 AM »

Also (fairly important) the initial direction vector of the viewing ray (dx,dy,dz) is normalised.

of course, but it seems you forgot about that:

Code:
; Now test if we're within the bailout distance
        if (t9 = gdist - x1*x1 - y1*y1 - z1*z1 \
                 + (x2=1.0/(dx*dx+dy*dy+dz*dz))*(t11=x1*dx+y1*dy+z1*dz)^2)>=0.0

No I didn't forget - the transforms scale the direction vectors.
For transforms that have uniform scaling (x,y,z) and no skewing/shearing etc. - such as those for the Menger Sponge - the calculations can be simplified to avoid the recalculation of inverse of the scale of the normal since the value will be the same as the overall contractive scale (that's why the routine still uses the contractive scale values).
x2=1.0/(dx*dx+dy*dy+dz*dz) = 1.0
Logged

David Makin
Global Moderator
Fractal Senior
******
Posts: 2286



Makin' Magic Fractals
WWW
« Reply #33 on: June 15, 2008, 09:22:29 PM »

Also (fairly important) the initial direction vector of the viewing ray (dx,dy,dz) is normalised.

of course, but it seems you forgot about that:

Code:
; Now test if we're within the bailout distance
        if (t9 = gdist - x1*x1 - y1*y1 - z1*z1 \
                 + (x2=1.0/(dx*dx+dy*dy+dz*dz))*(t11=x1*dx+y1*dy+z1*dz)^2)>=0.0

No I didn't forget - the transforms scale the direction vectors.
For transforms that have uniform scaling (x,y,z) and no skewing/shearing etc. - such as those for the Menger Sponge - the calculations can be simplified to avoid the recalculation of inverse of the scale of the normal since the value will be the same as the overall contractive scale (that's why the routine still uses the contractive scale values).
x2=1.0/(dx*dx+dy*dy+dz*dz) = 1.0

No because just prior to that we transformed the direction vectors:

        dxv[j] = dx = (x1=dx)*gt[k,0] + (y1=dy)*gt[k,3] + dz*gt[k,6]
        dyv[j] = dy = x1*gt[k,1] + y1*gt[k,4] + dz*gt[k,7]
        dzv[j] = dz = x1*gt[k,2] + y1*gt[k,5] + dz*gt[k,8]

Which means that they were at least scaled, possible skewed, sheared etc.

« Last Edit: June 15, 2008, 09:33:49 PM by David Makin » Logged

The meaning and purpose of life is to give life purpose and meaning.

http://www.fractalgallery.co.uk/
"Makin' Magic Music" on Jango
lycium
Fractal Supremo
*****
Posts: 1158



WWW
« Reply #34 on: June 15, 2008, 09:51:20 PM »

ah sorry, all clear now (i am used to code with const-declarations, which helps a lot in matters like these)! however, i think you can still avoid those operations if you know:

1. that (dx,dy,dz) is normalised in the beginning
2. 1 / |M| for all the xform matrices M

then you could compute (dx,dy,dz) = M(dx,dy,dz) * Mscale, where Mscale is inverse of detM, to simplify some of the later computations.
Logged

David Makin
Global Moderator
Fractal Senior
******
Posts: 2286



Makin' Magic Fractals
WWW
« Reply #35 on: June 16, 2008, 02:44:29 PM »

As I said:

"For transforms that have uniform scaling (x,y,z) and no skewing/shearing etc. - such as those for the Menger Sponge - the calculations can be simplified to avoid the recalculation of inverse of the scale of the normal since the value will be the same as the overall contractive scale (that's why the routine still uses the contractive scale values)."

I mean *all* the transforms in the IFS of course.
Note that with pure rotations you could also still use the overall scale value.
However if there is non-uniform scaling, or skewing or shearing etc. then you have to effectively re-normalise (because the overall transformation of dx,dy,dz is the accumulation of all the transforms from each depth in the tree)
Logged

The meaning and purpose of life is to give life purpose and meaning.

http://www.fractalgallery.co.uk/
"Makin' Magic Music" on Jango
Pages: 1 2 [3]   Go Down
  Print  
 
Jump to:  


Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM
Page created in 0.147 seconds with 24 queries. (Pretty URLs adds 0.006s, 2q)