POV-Ray : Newsgroups : povray.advanced-users : Help on isosurface - distances - other stuff... Server Time
1 Nov 2024 19:13:36 EDT (-0400)
  Help on isosurface - distances - other stuff... (Message 1 to 7 of 7)  
From: Jan Walzer
Subject: Help on isosurface - distances - other stuff...
Date: 12 Nov 2001 11:53:31
Message: <3beffe8b@news.povray.org>
Lets assume I have a function f(x,y,z) ...

this usually describes my isosurface ... The surface is all points, where
f(x,y,z)=0...

How can I now describe another function g(x,y,z) that describes for g(...)=0
all the
points, that have a distance d to the the surface of f() ?
I don't have any ideas 'bout the gradient of f() ... it can go from 0 to oo
(literally)...

Another Problem I have is the following:
Lets assume I have a sphere ... (OK, thats easy)
Lets assume I want to make it spikey (that's not hard)
Lets assume I want to do something with the bozo-pattern ...

function {
    sphere(....)+pattern(bozo transform{some scaling})
    }

This gives me two things ...
1) The sphere mostly looks like I wanted it ...
2) The function also contains some single "drops", that are not connected to
the sphere
   Of course, they are mathematically correct, but I want them to disappear.
I only want
   to see the parts of the surface that are directly connected to the
sphere-function...

   I have no concrete idea of how to achieve this...
   I tried something like: take the distance to the sphere and power this by
$HighValue
   before adding the pattern, but that didn't help me much, because it also
increased the
   gradient inside the sphere, and so other functions didn't work any longer
as expected ...


I know, there are specialists, experts, Iso-gurus out there, who can help me
to control these damn functions the way I want to ;)

--
Jan Walzer <jan### [at] lzernet>


Post a reply to this message

From: Christoph Hormann
Subject: Re: Help on isosurface - distances - other stuff...
Date: 12 Nov 2001 13:15:09
Message: <3BF011A6.74A93A9A@gmx.de>
Jan Walzer wrote:
> 
> Lets assume I have a function f(x,y,z) ...
> 
> this usually describes my isosurface ... The surface is all points, where
> f(x,y,z)=0...
> 
> How can I now describe another function g(x,y,z) that describes for g(...)=0
> all the
> points, that have a distance d to the the surface of f() ?
> I don't have any ideas 'bout the gradient of f() ... it can go from 0 to oo
> (literally)...

I must admit i have no idea what you are talking about here.

> Another Problem I have is the following:
> Lets assume I have a sphere ... (OK, thats easy)
> Lets assume I want to make it spikey (that's not hard)
> Lets assume I want to do something with the bozo-pattern ...
> 
> function {
>     sphere(....)+pattern(bozo transform{some scaling})
>     }
> 
> This gives me two things ...
> 1) The sphere mostly looks like I wanted it ...

Nice. ;-)

> 2) The function also contains some single "drops", that are not connected to
> the sphere
>    Of course, they are mathematically correct, but I want them to disappear.
> I only want
>    to see the parts of the surface that are directly connected to the
> sphere-function...

It's not possible to simply remove this separations, but if you have a
noise function that is constant in radial direction of the sphere, there
will only be one surface, it will look different of course (meaning there
are no 'overhangs' in radial direction either.

The following is just made from a quick glance in the math formulas for
spherical coordinates so probably won't really produce what you want, but
it should give an idea what i mean:

#declare fn_x=function { f_noise3d(x*5, y*5, z*5) }                   
                  
isosurface {
  function { sqrt(x^2 + y^2 + z^2) - 0.1 - fn_x(atan2(x^2 + y^2,z),
atan2(y,x), 0)*3 }
  contained_by { box { -4, 4 } }   
  max_gradient 20
}  

Christoph


-- 
Christoph Hormann <chr### [at] gmxde>
IsoWood include, radiosity tutorial, TransSkin and other 
things on: http://www.schunter.etc.tu-bs.de/~chris/


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Help on isosurface - distances - other stuff...
Date: 12 Nov 2001 17:59:44
Message: <3BF0541A.62BC8C1F@hotmail.com>
Jan Walzer wrote:
> 
> Lets assume I have a function f(x,y,z) ...
> 
> this usually describes my isosurface ... The surface is all points, where
> f(x,y,z)=0...
> 
> How can I now describe another function g(x,y,z) that describes for g(...)=0
> all the
> points, that have a distance d to the the surface of f() ?
>...

Jan,
I have tried to put together some iso-code
below in order to try to solve your problem.

I hope it does what you need.

Be prepared for looooong redering times.


Tor Olav


// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
// Copyright 2001 by Tor Olav Kristensen
// Email: tor### [at] hotmailcom
// http://www.crosswinds.net/~tok
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#version 3.5;

#include "colors.inc"
#include "functions.inc"

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

// The "original" function. (f_torus() from functions.inc)
#declare Rmaj = 0.5;
#declare Rmin = 0.2;
#declare Fn = function { f_torus(x, y, z, Rmaj, Rmin) }

// Partial derivatives of function calculated numerically.
// (An analytical calculated partial derivatives of function
// would be better though.)
#declare H = 0.0001;
#declare DerxFn = function { (Fn(x + H, y, z) - Fn(x - H, y, z))/2/H }
#declare DeryFn = function { (Fn(x, y + H, z) - Fn(x, y - H, z))/2/H }
#declare DerzFn = function { (Fn(x, y, z + H) - Fn(x, y, z - H))/2/H }

/*
// As long as these functions are only used within the LDFn()
// function below, they can be simplified a bit:
#declare DerxFn = function { Fn(x + H, y, z) - Fn(x - H, y, z) }
#declare DeryFn = function { Fn(x, y + H, z) - Fn(x, y - H, z) }
#declare DerzFn = function { Fn(x, y, z + H) - Fn(x, y, z - H) }
*/

// Gradient vector at any point; <x, y, z> is:
// vGradient(x, y, z) =
// <DerxFn(x, y, z), DeryFn(x, y, z), DerzFn(x, y, z)>

// Length of gradient vector:
#declare LDFn =
function {
  sqrt(
    DerxFn(x, y, z)^2 +
    DeryFn(x, y, z)^2 +
    DerzFn(x, y, z)^2
  ) + 1e-8 // To avoid division by zero
}

// Normalized gradient vector for function at <x, y, z> is:
// vNormalizedGradient(x, y, z) = vGradient(x, y, z)/LDFn(x, y, z) =
// <DerxFn(x, y, z), DeryFn(x, y, z), DerzFn(x, y, z)>/LDFn(x, y, z)

#declare DerxFnNormalized = function { DerxFn(x, y, z)/LDFn(x, y, z) }
#declare DeryFnNormalized = function { DeryFn(x, y, z)/LDFn(x, y, z) }
#declare DerzFnNormalized = function { DerzFn(x, y, z)/LDFn(x, y, z) }

// Now assume that the surface of the "original" function lies in the
// opposite direction of the gradient vector.
// Also assume that it will be at:
// <x, y, z> - Dist*vNormalizedGradient(x, y, z)
// (Note that this may only be true for small Dist values.)

#declare Dist = 0.1;
// See note below
#declare xNew = function { x - Dist*DerxFnNormalized(x, y, z) }
#declare yNew = function { y - Dist*DeryFnNormalized(x, y, z) }
#declare zNew = function { z - Dist*DerzFnNormalized(x, y, z) }

#declare OutsideFn =
function { Fn(xNew(x, y, z), yNew(x, y, z), zNew(x, y, z)) }

isosurface {
//  function { Fn(x, y, z) }      // "Original" surface
  function { OutsideFn(x, y, z) } // Surface "outside" this
  contained_by {
    box {
      -<Rmaj + Rmin + Dist, Rmin + Dist, Rmaj + Rmin + Dist>,
       <Rmaj + Rmin + Dist, Rmin + Dist, Rmaj + Rmin + Dist>
    }
  }
  max_gradient 4
  pigment { color White }
}

// A little check
intersection {
  torus { Rmaj, (Rmin + Dist)*1.01 }
  plane { -z, 0 }
  pigment { color Cyan } 
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

background { color Blue/2 }

light_source { <0, 4, -3>*10 color White }

camera {
  location <1, 1, -1>
  look_at <0, 0, 0>
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

/*
// Note:
// Try to replace the 19 lines below the "See note below" line with
// these lines:

#declare Noise = 0.1;
#declare DD = function { Dist + Noise*f_noise3d(5*x, 5*y, 5*z) }
#declare xNew = function { x - DD(x, y, z)*DerxFnNormalized(x, y, z) }
#declare yNew = function { y - DD(x, y, z)*DeryFnNormalized(x, y, z) }
#declare zNew = function { z - DD(x, y, z)*DerzFnNormalized(x, y, z) }

#declare OutsideFn =
function { Fn(xNew(x, y, z), yNew(x, y, z), zNew(x, y, z)) }

#declare Rsmall = Rmin + Dist + Noise;

isosurface {
  function { OutsideFn(x, y, z) }
  contained_by {
    box {
      -<Rmaj + Rsmall, Rsmall, Rmaj + Rsmall>,
       <Rmaj + Rsmall, Rsmall, Rmaj + Rsmall>
    }
  }
  max_gradient 10
  pigment { color White }
}
*/

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7


Post a reply to this message

From: Slime
Subject: Re: Help on isosurface - distances - other stuff...
Date: 13 Nov 2001 00:25:57
Message: <3bf0aee5$1@news.povray.org>
> I only want
>    to see the parts of the surface that are directly connected to the
> sphere-function...
>
>    I have no concrete idea of how to achieve this...


All you have to do is take the noise function and evaluate it not at
<x,y,z>, but at the *normalized* version of <x,y,z> multiplied by the radius
of the sphere. That means this noise function you create will return the
same value at <1,1,1>, <3,3,3>, and <100,100,100>. The distance from the
origin won't change the value of the function.

To normalize a vector, you divide the vector by it's length.
vnormalize(<x,y,z>) = <x,y,z>/sqrt(x^2+y^2+z^2). So, here's the noise
function that you need:

#declare mynoise3d = function (x,y,z,r)
{f_noise3d(x/sqrt(x^2+y^2+z^2)*r,y/sqrt(x^2+y^2+z^2)*r,z/sqrt(x^2+y^2+z^2)*r
)}

Then just use that function instead of the regular 3d noise function, and it
should work as you expect it. The greater r is, the more detail there will
be in the noise.

> How can I now describe another function g(x,y,z) that describes for
g(...)=0
> all the
> points, that have a distance d to the the surface of f() ?

As for this, it can be very complicated. It's something that will require a
lot of math, very tough math in many cases, and may require very different
methods for different functions. For a sphere, obviously, the distance from
the surface is the length of the vector <x,y,z> minus the radius of the
sphere. For anything more complicated than that, it can get *extremely* hard
to calculate. There may be ways to approximate these functions, but they
would most likely require an algorithm, which is something povray's
function{}s can't handle. If your function contains a 3d noise or pigment
function, forget about it. My suggestion is to come up with a different way
of creating the effect you need.

- Slime
[ http://www.slimeland.com/ ]
[ http://www.slimeland.com/images/ ]


Post a reply to this message

From: Jan Walzer
Subject: Re: Help on isosurface - distances - other stuff...
Date: 13 Nov 2001 01:24:38
Message: <3bf0bca6@news.povray.org>
This looks good, what I've seen at the first glance ...
I'll try it, when I'm back, this afternoon ...

Thanx a lot ...

--
Jan Walzer <jan### [at] lzernet>


Post a reply to this message

From: Jan Walzer
Subject: Re: Help on isosurface - distances - other stuff...
Date: 13 Nov 2001 01:34:22
Message: <3bf0beee@news.povray.org>
OK ... nice ... ;)
That's what happens, if you make your examples simple .... ;)

Of course this is a quite logical way...

And now imagine, not to use a sphere, but something more concave ...
I hope a torus will do the example ...

If I do it this way for a torus, then you would be able to see, that
there's some cheating, and not the original bozo-function ...

What I wan't is not really to cut away these separated parts, but to avoid
these "bubbles", that come from adding one function to another ...

My idea was, to raise the first function by a very high power...
that would have decreased these separation, but also decreased the depth
of the deformation of the parts, that I wantet to ...

OK ... I can imagine, it's hard to understand, what I want and what I did...
so I'll see if I can post a pic this afternoon, when I'm back ...

Thanx anyway

--
Jan Walzer <jan### [at] lzernet>


Post a reply to this message

From: Slime
Subject: Re: Help on isosurface - distances - other stuff...
Date: 13 Nov 2001 10:50:27
Message: <3bf14143$1@news.povray.org>
> If I do it this way for a torus, then you would be able to see, that
> there's some cheating, and not the original bozo-function ...
>
> What I wan't is not really to cut away these separated parts, but to avoid
> these "bubbles", that come from adding one function to another ...

Well, with a torus, you could modify the function so that it takes the same
value at any point moving away from the surface of the *torus* instead of a
sphere. That would be more difficult than the sphere example I gave, and, of
course, get even harder when working with more complex functions. Usually,
if I have a shape that complex, I just multiply the noise function by a
small enough value that no overhangs or floating peices appear. The downside
is that you can't have huge bumps. I'm not sure if there's an easy solution
to that problem.

- Slime
[ http://www.slimeland.com/ ]
[ http://www.slimeland.com/images/ ]


Post a reply to this message

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