POV-Ray : Newsgroups : povray.general : weird merge Server Time
11 Aug 2024 07:11:15 EDT (-0400)
  weird merge (Message 1 to 8 of 8)  
From: Remco de Korte
Subject: weird merge
Date: 6 Sep 1999 18:00:23
Message: <37D43439.27A3F265@xs4all.nl>
/*
There's something weird with the following code:
*/

camera{location <0,0,-13.5> look_at<0,0,0> angle 30}

light_source{<-200,100,-150> color rgb <1,1,1>.1}

plane{z,600 hollow on pigment{rgb .25}}
   
#declare xx=1.9;
#declare yy=.5;

merge{
  sphere{<-xx,-yy,0>,.1}
  sphere{<xx,-yy,0>,.1}
  sphere{<-xx,yy,0>,.1}
  sphere{<xx,yy,0>,.1}
  cylinder{<-xx,-yy,0><xx,-yy,0>,.1}
  cylinder{<-xx,yy,0><xx,yy,0>,.1}
  cylinder{<-xx,-yy,0><-xx,yy,0>,.1}
  cylinder{<xx,-yy,0><xx,yy,0>,.1}

  cylinder{<-xx,-yy,0><-xx,-yy,5>,.1}
  cylinder{<xx,-yy,0><xx,-yy,5>,.1}
  cylinder{<-xx,yy,0><-xx,yy,5>,.1}
  cylinder{<xx,yy,0><xx,yy,5>,.1}
        
  box{<-xx,-yy-.1,0><xx,yy+.1,5>}
  box{<-xx-.1,-yy,0><xx+.1,yy,5>}
  pigment{rgb 5}
}

/*
What you should get is a bevelled box. 
If I make this into a union it's okay,
but with merge the inner part is gone.

Is this some known weird merge-behaviour
or am I making a stupid mistake?
(I thought union and merge should look
the same on the outside)

Cheerio,

Remco


Post a reply to this message

From: Larry Fontaine
Subject: Re: weird merge
Date: 6 Sep 1999 20:03:37
Message: <37D454B9.DD347544@isd.net>
Remco de Korte wrote:

> /*
> There's something weird with the following code:
> */
>
> camera{location <0,0,-13.5> look_at<0,0,0> angle 30}
>
> light_source{<-200,100,-150> color rgb <1,1,1>.1}
>
> plane{z,600 hollow on pigment{rgb .25}}
>
> #declare xx=1.9;
> #declare yy=.5;
>
> merge{
>   sphere{<-xx,-yy,0>,.1}
>   sphere{<xx,-yy,0>,.1}
>   sphere{<-xx,yy,0>,.1}
>   sphere{<xx,yy,0>,.1}
>   cylinder{<-xx,-yy,0><xx,-yy,0>,.1}
>   cylinder{<-xx,yy,0><xx,yy,0>,.1}
>   cylinder{<-xx,-yy,0><-xx,yy,0>,.1}
>   cylinder{<xx,-yy,0><xx,yy,0>,.1}
>
>   cylinder{<-xx,-yy,0><-xx,-yy,5>,.1}
>   cylinder{<xx,-yy,0><xx,-yy,5>,.1}
>   cylinder{<-xx,yy,0><-xx,yy,5>,.1}
>   cylinder{<xx,yy,0><xx,yy,5>,.1}
>
>   box{<-xx,-yy-.1,0><xx,yy+.1,5>}
>   box{<-xx-.1,-yy,0><xx+.1,yy,5>}
>   pigment{rgb 5}
> }
>
> /*
> What you should get is a bevelled box.
> If I make this into a union it's okay,
> but with merge the inner part is gone.
>
> Is this some known weird merge-behaviour
> or am I making a stupid mistake?
> (I thought union and merge should look
> the same on the outside)
>
> Cheerio,
>
> Remco

You have coincident surfaces. Use this code instead:

merge {
  sphere{<-xx,-yy,0>,.1}
  sphere{<xx,-yy,0>,.1}
  sphere{<-xx,yy,0>,.1}
  sphere{<xx,yy,0>,.1}
  cylinder{<-xx,-yy,0><xx,-yy,0>,.1}
  cylinder{<-xx,yy,0><xx,yy,0>,.1}
  cylinder{<-xx,-yy,0><-xx,yy,0>,.1}
  cylinder{<xx,-yy,0><xx,yy,0>,.1}

  cylinder{<-xx,-yy,0><-xx,-yy,5>,.1}
  cylinder{<xx,-yy,0><xx,-yy,5>,.1}
  cylinder{<-xx,yy,0><-xx,yy,5>,.1}
  cylinder{<xx,yy,0><xx,yy,5>,.1}

  box{<-xx,-yy-.1,0.00001><xx,yy+.1,5>}
  box{<-xx-.1,-yy,0><xx+.1,yy,5>}
}


Post a reply to this message

From: Remco de Korte
Subject: Re: weird merge
Date: 6 Sep 1999 21:12:23
Message: <37D4679B.6DD27FDB@xs4all.nl>
Larry Fontaine wrote:
> 
> You have coincident surfaces. 
> 
Yes I understand, but I didn't know that mattered. It doesn't for a union. 
Somehow I think your solution, though effective, isn't all that elegant.
:)

Thanks anyhow,

Remco


Post a reply to this message

From: Ron Parker
Subject: Re: weird merge
Date: 6 Sep 1999 22:30:44
Message: <37d478bc.623018958@news.povray.org>
On Tue, 07 Sep 1999 03:17:15 +0200, Remco de Korte
<rem### [at] xs4allnl> wrote:

>Larry Fontaine wrote:
>> 
>> You have coincident surfaces. 
>> 
>Yes I understand, but I didn't know that mattered. It doesn't for a union. 
>Somehow I think your solution, though effective, isn't all that elegant.
>:)

It does matter.  Merge is actually an intersection, believe it or not,

though it's not represented that way internally like difference is. 
Nevertheless, anything that's important for an intersection is
important for a merge as well.

merge {object a object b} 

is equivalent to (but perhaps a little faster than)

intersection {object {a inverse} object {b inverse} inverse }


Post a reply to this message

From: Larry Fontaine
Subject: Re: weird merge
Date: 7 Sep 1999 17:41:21
Message: <37D584DE.28EE5EF3@isd.net>
Ron Parker wrote:

> It does matter.  Merge is actually an intersection, believe it or not,
>
> though it's not represented that way internally like difference is.
> Nevertheless, anything that's important for an intersection is
> important for a merge as well.
>
> merge {object a object b}
>
> is equivalent to (but perhaps a little faster than)
>
> intersection {object {a inverse} object {b inverse} inverse }

In addition to this,
   difference { object a object b }
is the same as
   intersection { object a object {b inverse } }

I think the latter computes faster? Maybe bounding is more accurate because in
diff. you have to specify your own bound...


Post a reply to this message

From: Chris Huff
Subject: Re: weird merge
Date: 7 Sep 1999 17:56:34
Message: <37D58A59.D2995EFD@compuserve.com>
They are both the same, there shouldn't be any difference(sorry!)
between the speeds. If speed is important, you should manually bound
both difference and intersection, because the program can't reliably
determine the best bounds for them.(I haven't done this in my macro
collection, and it needs it badly for some objects composed of many
primitives. For simpler objects, the gain is so small it can be
unnoticeable.)


Post a reply to this message

From: Larry Fontaine
Subject: Re: weird merge
Date: 7 Sep 1999 18:04:08
Message: <37D58A36.4EC7180B@isd.net>
Remco de Korte wrote:

> Larry Fontaine wrote:
> >
> > You have coincident surfaces.
> >
> Yes I understand, but I didn't know that mattered. It doesn't for a union.
> Somehow I think your solution, though effective, isn't all that elegant.
> :)

It looks like you only want to round four fo the edges of the box, not all
twelve? Otherwise, with twelve, you'd have 12 cylinders, six spheres and some
boxes, and they could all be perfectly positioned without coincidence.


Post a reply to this message

From: Ron Parker
Subject: Re: weird merge
Date: 8 Sep 1999 09:27:40
Message: <37d6644c@news.povray.org>
On Tue, 07 Sep 1999 16:34:22 -0500, Larry Fontaine wrote:

>In addition to this,
>   difference { object a object b }
>is the same as
>   intersection { object a object {b inverse } }
>
>I think the latter computes faster? 

There's no way to know, because POV internally turns a difference into
the equivalent intersection.  Other than a little bit in the parser, 
there is no "difference" code in POV.


Post a reply to this message

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