POV-Ray : Newsgroups : povray.newusers : (vector) sum of two objects Server Time
31 Jul 2024 04:18:57 EDT (-0400)
  (vector) sum of two objects (Message 43 to 52 of 52)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: Peter Popov
Subject: Re: (vector) sum of two objects
Date: 25 Apr 2003 07:27:39
Message: <mp6iav4i5vf8s4ggpci0trm5rr8rga7134@4ax.com>
On Thu, 24 Apr 2003 14:47:51 +0200, Achill <ach### [at] matumde> wrote:

>That sounds great!
>
>I am very curious... :-)

Reading through the thread I see it might not help your case much,
because I'm talking about discrete sets of scalars, vectors or
strings, and you're talking about continuous sets of points
(surfaces). Won't help much.

Why don't you just use merge instead? :)


Peter Popov ICQ : 15002700
Personal e-mail : pet### [at] vipbg
TAG      e-mail : pet### [at] tagpovrayorg


Post a reply to this message

From: Christopher James Huff
Subject: Re: (vector) sum of two objects
Date: 25 Apr 2003 16:11:44
Message: <cjameshuff-AA9970.16121325042003@netplex.aussie.org>
In article <3ea91586$1@news.povray.org>,


> The same concept is used for pen styles in 2D drawing programs: the center
> of the pen is moved along a path, and all points reachable with the pen
> shape from the current location on this path are painted with the drawing
> color, i.e. all painted points are obtained by location_vector+shape_vector
> for all possible location_vectors and shape_vectors.

Summing an object with a single point is easy:

#macro MinkSumPO(Point, Object) object {Object translate Point} #end

;-)

I guess you *could* do it with arbitrary objects by positioning a large 
enough number of copies of one object so they overlap the other object:
Sum objects A and B:
for(big number of iterations)
    find random point pA on object A
    find random point pB on object B
    translate copy of object B by pA - pB
repeat until you have enough copies of B that overlap the area of A to 
get a smooth appearance. A few million should do for some simple smooth 
shapes...at least to give an idea of what the result should be.


> At least for meshes this should be possible, especially for convex shapes.

Not entirely right. You still end up with a bunch of points, and the 
mesh you reconstruct from them may not be what you would expect from 
looking at the original meshes. You can't take just the vertex 
information and exactly reconstruct the original mesh...you can have 
several meshes with the same vertices, though you can often get 
something reasonable looking. Also, large triangles will result in large 
areas without any points, so you may want to subdivide large triangles 
before doing the 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

From: Christopher James Huff
Subject: Re: (vector) sum of two objects
Date: 25 Apr 2003 16:13:26
Message: <cjameshuff-119725.16140025042003@netplex.aussie.org>
In article <5johavcb3rjtc792kr1v29f36h5sf5r3q4@4ax.com>,
 ABX <abx### [at] abxartpl> wrote:

> If your set are "contignous" subsets of 3D space and you can express that set
> with some function where for elements (coordinates) from set this functions
> gives negative value then you can use isosurface{} object. parametric{} object
> can be also in area of your interest.

I don't see how you could do this...it wouldn't be the same as the sum 
of the functions. Could you clarify? You mean deriving a function for 
the object by hand and just using an isosurface to render it?

-- 
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

From:
Subject: Re: (vector) sum of two objects: Q&D SDL
Date: 25 Apr 2003 22:50:44
Message: <3ea9f404$1@news.povray.org>
/*
    The following scene is a quick-and-dirty brute force approximation
    for Minkowski sums. Two arbitrary shapes are minkowski-added by
    chosing many random points in the first given object, then adding
    them to the second object, i.e. making a translated copy of the
    second object. The number of copies should be high (1000 to 10000),
    the objects should be simple, esp. the second object. Inner points
    of the first object usually don't contribute anything visible to
    the sum because they translate the second object to a place where
    it will be surrounded by copies belonging to points in the vicinity
    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.

       Sputnik

*/


// Minkowski sum

// +SP8 +EP8 +D -F +W320 +H240

#macro Minkowski_sum (Copies, O1, O2)

  // preparations for sampling the bounding box of O1
  #local Min = min_extent (O1);
  #local Size = max_extent (O1)-Min;
  #local Rand = seed(123);

  union {

    #local I = 0; // counts inside-points
    #local N = 0; // counts tested points
    #while (I<Copies)
      // get a random point in the bounding box of O1
      #local Point = Min+Size*<rand(Rand),rand(Rand),rand(Rand)>;
      #local N = N+1;
      // if this point is inside O1 then ...
      #if (inside(O1, Point))
        // ... minkowski-add it to O2 and count it
        object { O2 translate Point }
        #local I = I+1;
        #end//if
      #end//while I

    // no "}" for union to allow application of a texture

    #debug concat ( str(I*100/N,10,2), "% successful inside tests\n" )

  #end//macro Minkowski_sum


#switch (2) // <-- choose an example here (1 .. 3)


  #case (1) // rounded box
    Minkowski_sum ( 10000,
      box { -4, 4 }
      sphere { 0, 1 }
      )
      texture { pigment { color rgb 1 } }
      }//the missing "}" for the union
    #break//1


  #case (2) // rounded box, improved
    Minkowski_sum ( 2000,
      difference { box { -4, 4 } box { -3.9, 3.9 } }
      sphere { 0, 1 }
      )
      texture { pigment { color rgb 1 } }
      }
    #break//2


  #case (3) // "coned" torus
    Minkowski_sum ( 1000,
      difference {
        torus { 5, 1 }
        torus { 5, 0.9 }
        }
        cone { 0, 2, 3*y, 0.5 }
      )
      texture { pigment { color rgb 1 } }
      }
    #break//3


  #case (4) // "torused" cone = 1.0*cone + 1.0*torus
    Minkowski_sum ( 1000,
      difference {
        cone { 0  *y, 2  , 3  *y, 0.5 }
        cone { 0.1*y, 1.9, 2.9*y, 0.4 }
        }
      torus { 5, 1 }
      )
      texture { pigment { color rgb 1 } }
      }
    #break//4


  #case (5) // 1.6*cone + 0.4*torus
    Minkowski_sum ( 1000,
      difference {
        cone { 0  *y, 2  , 3  *y, 0.5 }
        cone { 0.1*y, 1.9, 2.9*y, 0.4 }
        scale 1.6
        }
      torus { 5, 1 scale 0.4 }
      )
      texture { pigment { color rgb 1 } }
      }
    #break//5


  #case (6) // 0.4*cone + 1.6*torus
    Minkowski_sum ( 1000,
      difference {
        cone { 0  *y, 2  , 3  *y, 0.5 }
        cone { 0.1*y, 1.9, 2.9*y, 0.4 }
        scale 0.4
        }
      torus { 5, 1 scale 1.6 }
      )
      texture { pigment { color rgb 1 } }
      }
    #break//6


  #end//switch


light_source { <-100, 150, -50>, rgb 1 }

camera { location <-5, 10, -15> look_at -1.5*y }


Post a reply to this message

From: ABX
Subject: Re: (vector) sum of two objects
Date: 28 Apr 2003 02:19:32
Message: <nahpav41nl0hkk6gvto0tkoq0381td0uvp@4ax.com>
On Fri, 25 Apr 2003 16:14:00 -0400, Christopher James Huff
<cja### [at] earthlinknet> wrote:
> > If your set are "contignous" subsets of 3D space and you can express that set
> > with some function where for elements (coordinates) from set this functions
> > gives negative value then you can use isosurface{} object. parametric{} object
> > can be also in area of your interest.
>
> I don't see how you could do this...it wouldn't be the same as the sum 
> of the functions.

Where I said I mean sum of functions? Where I said I mean any sum ?
For the opinion "Converting arbitrary point sets into meshes or surfaces is a
difficult task" I replaied that isosurface can be considered as set of points
where desription of set is a given function. Of course the difficult part is
finding that function for given set which is another task. I just wanted point
out that isosurface can be a tool in mentioned "conversion".

ABX


Post a reply to this message

From: Christopher James Huff
Subject: Re: (vector) sum of two objects
Date: 28 Apr 2003 21:02:11
Message: <cjameshuff-39A8DD.21005128042003@netplex.aussie.org>
In article <nahpav41nl0hkk6gvto0tkoq0381td0uvp@4ax.com>,
 ABX <abx### [at] abxartpl> wrote:

> Where I said I mean sum of functions? Where I said I mean any sum ?

It was somewhat implied by your message, though it was too vague to mean 
much of anything.


> For the opinion "Converting arbitrary point sets into meshes or surfaces is a
> difficult task" I replaied that isosurface can be considered as set of points
> where desription of set is a given function. Of course the difficult part is
> finding that function for given set which is another task. I just wanted 
> point out that isosurface can be a tool in mentioned "conversion".

But you implied that knowing the functions would give you some way to 
find the sum...or were you talking about writing a function by hand that 
would give the same shape as the sum? Again, you haven't given a clear 
description of what you mean by using an isosurface for "conversion".

-- 
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

From: Christopher James Huff
Subject: Re: (vector) sum of two objects: Q&D SDL
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

From: ABX
Subject: Re: (vector) sum of two objects
Date: 30 Apr 2003 09:52:59
Message: <r5lvavo37qbp1mreph4lq704ang28l28t7@4ax.com>
On Mon, 28 Apr 2003 21:00:51 -0400, Christopher James Huff
<cja### [at] earthlinknet> wrote:
> > For the opinion "Converting arbitrary point sets into meshes or surfaces is a
> > difficult task" I replaied that isosurface can be considered as set of points
> > where desription of set is a given function. Of course the difficult part is
> > finding that function for given set which is another task. I just wanted 
> > point out that isosurface can be a tool in mentioned "conversion".
>
> But you implied that knowing the functions would give you some way to 
> find the sum...or were you talking about writing a function by hand that 
> would give the same shape as the sum? Again, you haven't given a clear 
> description of what you mean by using an isosurface for "conversion".

Ok, example: I have a set of points. The rule used to create this set is that
all points of this set have the same distance from center and all points have
their coordinates positive in value. So I can express this set as:

  A={ P(x,y,z) : x^2+y^2+z^2=distance^2 , x>0 , y>0 , z>0 }

I can easly "convert" it into isosurface, can't I?

ABX


Post a reply to this message

From: Christopher James Huff
Subject: Re: (vector) sum of two objects
Date: 30 Apr 2003 10:10:11
Message: <cjameshuff-937186.10081830042003@netplex.aussie.org>
In article <r5lvavo37qbp1mreph4lq704ang28l28t7@4ax.com>,
 ABX <abx### [at] abxartpl> wrote:

> Ok, example: I have a set of points. The rule used to create this set is that
> all points of this set have the same distance from center and all points have
> their coordinates positive in value. So I can express this set as:
> 
>   A={ P(x,y,z) : x^2+y^2+z^2=distance^2 , x>0 , y>0 , z>0 }
> 
> I can easly "convert" it into isosurface, can't I?

Have you actually tried this for more than a few hundred points? You 
would be much better off with a blob. And you won't end up with an 
object with a surface going through that point.

-- 
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

From: ABX
Subject: Re: (vector) sum of two objects
Date: 30 Apr 2003 10:23:38
Message: <hbmvavsst1l8bc6fprek1cdbj89rg32rdq@4ax.com>
On Wed, 30 Apr 2003 10:08:19 -0400, Christopher James Huff
<cja### [at] earthlinknet> wrote:
> > Ok, example: I have a set of points. The rule used to create this set is that
> > all points of this set have the same distance from center and all points have
> > their coordinates positive in value. So I can express this set as:
> > 
> >   A={ P(x,y,z) : x^2+y^2+z^2=distance^2 , x>0 , y>0 , z>0 }
> > 
> > I can easly "convert" it into isosurface, can't I?
>
> Have you actually tried this for more than a few hundred points? You 
> would be much better off with a blob. And you won't end up with an 
> object with a surface going through that point.

It seems you somehow overcomplicated this subject in your mind. What I was
refering is simple moving function from set definition with typical rules of
combining http://www.econym.demon.co.uk/isotut/combine.htm :

isosurface{
  function{min(x*x+y*y+z*z-R*R,-x,-y,-z)}
  open
  ... // other isosurface syntax
}

Of course from the begining this is a scpecial case when set does not contain
enumerated list of points but infinite surfaces. EOT!

ABX


Post a reply to this message

<<< Previous 10 Messages Goto Initial 10 Messages

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