POV-Ray : Newsgroups : povray.newusers : (vector) sum of two objects : Re: (vector) sum of two objects: Q&D SDL Server Time
31 Jul 2024 06:26:27 EDT (-0400)
  Re: (vector) sum of two objects: Q&D SDL  
From: Christopher James Huff
Date: 28 Apr 2003 21:21:39
Message: <cjameshuff-D2E6CD.21201928042003@netplex.aussie.org>
In article <3ea9f404$1@news.povray.org>,


>     The following scene is a quick-and-dirty brute force approximation
>     for Minkowski sums.

Jeez...you actually wrote the thing? I was joking.


>     of this inner point. So it's a good idea to remove inner points of
>     the first object; this will increase parse time (because it's
>     difficult to find points of a thin object), but will greatly
>     increase the quality of the surface of the minkowski sum (because
>     no copies are wasted). Modify the #switch value to see the
>     examples.

You use insideness tests to find points inside the object. This will 
fail for perfectly thin objects like triangles. Try tracing rays in 
random directions from random points inside the bounding box instead. 
Though this will probably not work for infinite objects, you shouldn't 
even be thinking about summing those.
Untested:

#declare VRand_On_Obj_Bailout = 10000;
#declare Minkowski_Sum_Stream = seed(95173);

#macro VRand_On_Obj(Obj, RS)
    #local Norm = < 0, 0, 0>;
    #local Pt = < 0, 0, 0>;
    #local Mn = min_extent(Obj);
    #local Mx = max_extent(Obj);
    #local J = 0;
    #while(Norm.x = 0 & Norm.y = 0 & Norm.z = 0 & J < 
VRand_On_Obj_Bailout)
        #local Pt = trace(Obj, VRand_In_Box(Mn, Mx, RS), 
VRand_On_Sphere(RS), Norm);
        #local J = J + 1;
    #end
    (Pt)
#end

#macro Minkowski_Sum(Obj1, Obj2, Samples)
    union {
    #local I = 0;
    #while(I < Samples)
        object {Obj2 translate VRand_On_Obj(Obj1, Minkowski_Sum_Stream)}
        #local I = I+1;
    #end//while I
    
    // no "}" for union to allow application of a texture
#end//macro Minkowski_sum

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tagpovrayorg
http://tag.povray.org/


Post a reply to this message

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