POV-Ray : Newsgroups : povray.binaries.images : CSG: difference: artefacts : Re: CSG: difference: artefacts Server Time
29 Apr 2024 00:21:18 EDT (-0400)
  Re: CSG: difference: artefacts  
From: Anthony D  Baye
Date: 17 Mar 2016 16:30:00
Message: <web.56eb1044e45cefaffd6b6fe10@news.povray.org>
"LanuHum" <Lan### [at] yandexru> wrote:
> ParticleSystem_Sphere_shape.inc:
> //numbers spheres = 1000
> #declare data_ParticleSystem_Sphere_shape_ob = union{
> object {data_Sphere_shape_001_ob scale 0.1 translate
> <1.602048,2.176796,0.704082>}
> object {data_Sphere_shape_001_ob scale 0.1 translate
> <-2.709654,0.306427,-0.592914>}
> .....
> .....
> .....
> object {data_Sphere_shape_001_ob scale 0.1 translate
> <-2.061681,1.452029,1.206769>}
> object {data_Sphere_shape_001_ob scale 0.1 translate
> <1.646683,1.532989,-1.656775>}
> texture{Default_texture}
> }
>
> Povscene .pov:
>
> #version 3.7;
>
> global_settings {
>     assumed_gamma 1.000000
>     max_trace_level 20
>     charset utf8
> }
> sky_sphere {
>     pigment {rgb<0.050, 0.050, 0.050>}
> }
>
> #declare Default_texture = texture{pigment {rgb 0.8}}
>
> #declare data_Sphere_shape_ob = sphere { 0,1
> }
> #declare data_Sphere_shape_001_ob = sphere { 0,1
> }
> #include "ParticleSystem_Sphere_shape.inc"
> difference{
> object {data_Sphere_shape_ob
>     texture {Default_texture}
>     matrix <2.798619, 0.000000, 0.000000,  0.000000, -0.000000, -2.798619,
> 0.000000, 2.798619, -0.000000,  0.000000, 0.000000, 0.000000>
> }
>
> object {data_ParticleSystem_Sphere_shape_ob texture{Default_texture}
> }
> }
>
> light_source {
>     <5.07,5.58,4.28>
>     color rgb<1, 1, 1>
>     fade_distance 25.0000000000
>     fade_power 1
> }
> camera {
>     perspective
>     location  <0,0,0>
>     look_at  <0,0,-1>
>     right <-1.7777777777777777, 0, 0>
>     up <0, 1, 0>
>     angle  49.134343
>     rotate  <-27.098163, 46.688390, -0.903519>
>     translate <7.481132, 5.343666, 6.507640>
> }
>
> Render result:

looks like a coincident surface of two small spheres in the same place.

If it were me, I'd add each new sphere to a union and test successive ones
against being inside that union.

e.g.

#declare testObj =
union {
    sphere { 0.0, 1.0 }
    }

difference {
    sphere { 0.0 1.0 }
#declare A = 0;
#declare missCount = 0;
#while(A < 1000)
// generate a new point P...
    #if(!inside(testObj, p))
        #declare testObj =
            union {
                testObj
                sphere { 0.0, 0.1 translate p }
                }
        sphere { 0.0, 0.1 p }
        #declare A = A + 1;
        #declare missCount = 0;
    #else
        #declare missCount = missCount + 1;
    #end

    #if(missCount = 100)
        #break
    #end
#end
    }

Guaranteed to give you 1000 small cutouts.

If you want to limit the amount of overlap, you can increase the size of the
spheres you add to the union.

Regards,
A.D.B.


Post a reply to this message

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