POV-Ray : Newsgroups : povray.advanced-users : can anyone suggest a better solution for my problem? : Re: can anyone suggest a better solution for my problem? Server Time
30 Jul 2024 02:19:22 EDT (-0400)
  Re: can anyone suggest a better solution for my problem?  
From: Mike Williams
Date: 28 Jun 2000 13:04:09
Message: <0o0G3AAO4aW5EwJN@econym.demon.co.uk>
Wasn't it Oded who wrote:
>This is more of of a mathematical problem than a practical one:
>can any one think of a better way to create the following object type:
>I was thinking, while trying to convert a dodchahedron to a 3d star, of an
>object that will give the user higher control of defining 'in' and 'out' in
>CSG objects. in pov-ray you can only define intersections, inverses and
>unions.
>I was thinking of more complicated rules, eg:
>    a point A is "inside" function (a1....a12) if it is         inside 11
>out of 12 objects.
>what i needed to do for that was to define a union of 12 intersections of 6
>objects which was was quite dirty (mathematically speaking)
>eventually i ended up writing a c program to raytrace these objects defined
>soly by the 12 objects.

Here's a method using MegaPov. 

Use the "if" isosurface operator 12 times and set the threshold to 1.5.

First of all you need to express each of your objects a1 to a12 as
isosurface functions. In the case of a stellated dodecahedron your
objects are planes, so that's not too hard. It helps if you ensure that
the point <0,0,0> is always on the "inside" of your objects, i.e.
a1(0,0,0)<0. E.g. for the two horizontal planes "y-1=0" and "y+1=0" use
functions  "y-1" and "-y-1"; the second plane is inverted so that
<0,0,0> is on the inside. 

The expression "if (a1, 1, 0)" returns the value 1 when a1>0 and returns
0 when a1<0. I.e. it returns 1 for points outside the a1 object and
returns 0 for points that are inside.

If we add together several "if"s, like 
 "function {if(a1,1,0) + if(a2,1,0) + ... + if(a12,1,0)}"
we get the number of objects which the point is outside. Set the
Threshold to 1.5 and you get the set of points which are outside at
least 1 but less than 2 of the objects. (If you set the threshold to an
integer value then there's a volume of points which satisfy the function
and you get slightly different results.)

Use "method 1". "method 2" gives awful results because the max_gradient
needs to be set to infinity. "method 2 eval" gives good results but
takes a very long time because it evaluates the max_gradient to have a
very high value.

A slight problem with this method is that some parts of the object seem
to be erroneously unlit. I guess it's getting confused about which side
of the surface is the interior.


-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

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