POV-Ray : Newsgroups : povray.binaries.images : isosurface problem : isosurface problem Server Time
8 Aug 2024 20:22:03 EDT (-0400)
  isosurface problem  
From: Bill Pragnell
Date: 11 May 2005 11:50:01
Message: <web.428227ff92ff4ee0731f01d10@news.povray.org>
Right then, all you isosurface gurus out there: perhaps you can help me with
this.

Here's the problem. I'm trying to create a tetrahedral asteroid using an
isosurface. I've written a function which comprises four spheres, six
cylinders and a tetrahedron with its vertices and edges trimmed using a
functional intersection, merged to produce a perfect rounded tetrahedron
(first picture). I'm then boulderifying this base shape by adding crackle
and agate pigment functions.

No problem so far, I hear you say.

However, there appears to be a mismatch between the planar faces and the
curved edges which produces "fault lines" (second picture). I've tried
upping accuracy and max_gradient to no avail, and I've tried adding /
subtracting the pigment functions in various combinations - no good. Can
anyone shed any light on this bizarre artefact?

Source code, in case I'm being stupid:

// rounded tetrahedron function
// a is 'radius' of outcube
// b is radius of edge curves
#declare fn_rounded_tetra = function(x, y, z, a, b) {
  min( // backside
       max( (sqrt(0.5*(x+y)*(x+y) + (z-a)*(z-a)) - b),
            (-x+y-2*a),
            (x-y-2*a) ),
       // frontside
       max( (sqrt(0.5*(x-y)*(x-y) + (z+a)*(z+a)) - b),
            (x+y-2*a),
            (-x-y-2*a) ),
       // topside
       max( (sqrt(0.5*(x+z)*(x+z) + (y-a)*(y-a)) - b),
            (-x+z-2*a),
            (x-z-2*a) ),
       // bottomside
       max( (sqrt(0.5*(x-z)*(x-z) + (y+a)*(y+a)) - b),
            (-x-z-2*a),
            (x+z-2*a) ),
       // leftside
       max( (sqrt(0.5*(y-z)*(y-z) + (x+a)*(x+a)) - b),
            (y+z-2*a),
            (-y-z-2*a) ),
       // rightside
       max( (sqrt(0.5*(y+z)*(y+z) + (x-a)*(x-a)) - b),
            (y-z-2*a),
            (-y+z-2*a) ),
       // vertices
       f_sphere(x+a, y-a, z-a, b),
       f_sphere(x-a, y-a, z+a, b),
       f_sphere(x+a, y+a, z+a, b),
       f_sphere(x-a, y+a, z-a, b),
       // plane faces
       max( (x+y+z -( (a*sin(radians(f_f)/2)+b) / sin(radians(f_f)/2) )),
            (-x+y-z-( (a*sin(radians(f_f)/2)+b) / sin(radians(f_f)/2) )),
            (x-y-z -( (a*sin(radians(f_f)/2)+b) / sin(radians(f_f)/2) )),
            (-x-y+z-( (a*sin(radians(f_f)/2)+b) / sin(radians(f_f)/2) )),
            (y -  (a+b*cos(radians((180-f_f))/2))),
            (-y - (a+b*cos(radians((180-f_f))/2))),
            (x -  (a+b*cos(radians((180-f_f))/2))),
            (-x - (a+b*cos(radians((180-f_f))/2))),
            (z -  (a+b*cos(radians((180-f_f))/2))),
            (-z - (a+b*cos(radians((180-f_f))/2))),
            (-x+y+z - 2*(sqrt(3*a*a) + b*cos(radians((180-f_e))/2)) ),
            (x+y-z  - 2*(sqrt(3*a*a) + b*cos(radians((180-f_e))/2)) ),
            (x-y+z  - 2*(sqrt(3*a*a) + b*cos(radians((180-f_e))/2)) ),
            (-x-y-z - 2*(sqrt(3*a*a) + b*cos(radians((180-f_e))/2)) ) ) ) }

#declare Boulder = isosurface {
                        function { fn_rounded_tetra(x,y,z,10,1)
                                   + fn_agate(x/4,y/4,z/4).gray*0.3
                                   - fn_crack(x/4,y/4,z/4).gray*0.75 }
                        max_gradient 4
                        contained_by { box {-15, 15 } }
                        pigment { color White } }


Post a reply to this message


Attachments:
Download 'tetra2.jpg' (25 KB)

Preview of image 'tetra2.jpg'
tetra2.jpg


 

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.