POV-Ray : Newsgroups : povray.general : Strange behaviour? Server Time
4 Nov 2024 17:37:38 EST (-0500)
  Strange behaviour? (Message 1 to 9 of 9)  
From: Lutz Kretzschmar
Subject: Strange behaviour?
Date: 5 Oct 1999 07:14:25
Message: <37f9d4e7.14580615@194.174.214.110>
Hi All,

while trying to track down a bug I found that negative scaling can
make objects disappear and was wondering (not being too well-versed in
POV) whether this is legal or not:


default { pigment { color rgb <1,1,0> }}

union { 
  sphere {
    <-1,0,0>,1
  }
  sphere { // Sphere101
    <1,0,0>,1
  }
  cylinder { // Cylndr034
    <-1,0,0>, <1,0,0>, 0.7 
  }
  scale 1 // <- Change to -1 and see the spheres disappear
}
                                

light_source
{
  0*x // light's position (translated below)
  color red 1.0  green 1.0  blue 1.0  // light's color
  translate <20, 40, 50>
}
                                
camera { location <0,0,6> look_at 0 }

The docs do not say anything about negative scaling. It is
inconsistent in that the cylinder does not disappear, though.

Thoughts?

- Lutz
  email : lut### [at] stmuccom
  Web   : http://www.stmuc.com/moray


Post a reply to this message

From: Gilles Tran
Subject: Re: Strange behaviour?
Date: 5 Oct 1999 08:28:10
Message: <37F9EF9B.DD0252DD@inapg.inra.fr>
Pretty strange. Negative scaling is perhaps the most useful undocumented
feature of pov.
Could be an epsilon problem + float-to-vector promotion problem ????
scale -1*<1,1.0001,1> works all right
Gilles

Lutz Kretzschmar wrote:

> Hi All,
>
> while trying to track down a bug I found that negative scaling can
> make objects disappear and was wondering (not being too well-versed in
> POV) whether this is legal or not:
>
> default { pigment { color rgb <1,1,0> }}
>
> union {
>   sphere {
>     <-1,0,0>,1
>   }
>   sphere { // Sphere101
>     <1,0,0>,1
>   }
>   cylinder { // Cylndr034
>     <-1,0,0>, <1,0,0>, 0.7
>   }
>   scale 1 // <- Change to -1 and see the spheres disappear
> }
>
>
> light_source
> {
>   0*x // light's position (translated below)
>   color red 1.0  green 1.0  blue 1.0  // light's color
>   translate <20, 40, 50>
> }
>
> camera { location <0,0,6> look_at 0 }
>
> The docs do not say anything about negative scaling. It is
> inconsistent in that the cylinder does not disappear, though.
>
> Thoughts?
>
> - Lutz
>   email : lut### [at] stmuccom
>   Web   : http://www.stmuc.com/moray


Post a reply to this message

From: Margus Ramst
Subject: Re: Strange behaviour?
Date: 5 Oct 1999 09:06:05
Message: <37F9F793.C93F696C@peak.edu.ee>
The code itself is OK. The problem seems to be with automatic bounding. Add
manual bounding to the union and the spheres reappear.
Also, if you replace the central cylinder with a sphere, this sphere also
disappears upon scaling. So I don't think the problem is with bounding boxes not
getting transformed (you can also check this by placing the camera along the X
axis - the spheres still won't appear).
Anyway I'm pretty confident it's a bug.

Margus

Lutz Kretzschmar wrote:
> 
> Hi All,
> 
> while trying to track down a bug I found that negative scaling can
> make objects disappear and was wondering (not being too well-versed in
> POV) whether this is legal or not:
> 
> default { pigment { color rgb <1,1,0> }}
> 
> union {
>   sphere {
>     <-1,0,0>,1
>   }
>   sphere { // Sphere101
>     <1,0,0>,1
>   }
>   cylinder { // Cylndr034
>     <-1,0,0>, <1,0,0>, 0.7
>   }
>   scale 1 // <- Change to -1 and see the spheres disappear
> }
> 
> 
> light_source
> {
>   0*x // light's position (translated below)
>   color red 1.0  green 1.0  blue 1.0  // light's color
>   translate <20, 40, 50>
> }
> 
> camera { location <0,0,6> look_at 0 }
> 
> The docs do not say anything about negative scaling. It is
> inconsistent in that the cylinder does not disappear, though.
> 
> Thoughts?
> 
> - Lutz
>   email : lut### [at] stmuccom
>   Web   : http://www.stmuc.com/moray


Post a reply to this message

From: Fabien Mosen
Subject: Re: Strange behaviour?
Date: 5 Oct 1999 16:37:41
Message: <37FA617B.7DF72EC3@skynet.be>
Margus Ramst wrote:
> 
> The code itself is OK. The problem seems to be with automatic bounding. Add
> manual bounding to the union and the spheres reappear.

Turning the vista display on (+UD) shows that the bounding is present,
tough it doesn't work as expected...

Fabien.


Post a reply to this message

From: Bob Hughes
Subject: Re: Strange behaviour?
Date: 5 Oct 1999 17:40:49
Message: <37fa7061@news.povray.org>
The 'sphere' is definately a volitle primitive from what I have seen.  The
bug notion sounds very plausible, at least in the sense that maybe it could
be hardened against such defects maybe.  Possibly not a true bug in the
sense of what is normally expected in everyday use.

Bob

Margus Ramst <mar### [at] peakeduee> wrote in message
news:37F9F793.C93F696C@peak.edu.ee...
> The code itself is OK. The problem seems to be with automatic bounding.
Add
> manual bounding to the union and the spheres reappear.
> Also, if you replace the central cylinder with a sphere, this sphere also
> disappears upon scaling. So I don't think the problem is with bounding
boxes not
> getting transformed (you can also check this by placing the camera along
the X
> axis - the spheres still won't appear).
> Anyway I'm pretty confident it's a bug.
>
> Margus
>
> Lutz Kretzschmar wrote:
> >
> > Hi All,
> >
> > while trying to track down a bug I found that negative scaling can
> > make objects disappear and was wondering (not being too well-versed in
> > POV) whether this is legal or not:
> >
> > default { pigment { color rgb <1,1,0> }}
> >
> > union {
> >   sphere {
> >     <-1,0,0>,1
> >   }
> >   sphere { // Sphere101
> >     <1,0,0>,1
> >   }
> >   cylinder { // Cylndr034
> >     <-1,0,0>, <1,0,0>, 0.7
> >   }
> >   scale 1 // <- Change to -1 and see the spheres disappear
> > }
> >
> >
> > light_source
> > {
> >   0*x // light's position (translated below)
> >   color red 1.0  green 1.0  blue 1.0  // light's color
> >   translate <20, 40, 50>
> > }
> >
> > camera { location <0,0,6> look_at 0 }
> >
> > The docs do not say anything about negative scaling. It is
> > inconsistent in that the cylinder does not disappear, though.
> >
> > Thoughts?
> >
> > - Lutz
> >   email : lut### [at] stmuccom
> >   Web   : http://www.stmuc.com/moray


Post a reply to this message

From: Mark Wagner
Subject: Re: Strange behaviour?
Date: 6 Oct 1999 01:11:57
Message: <37fada1d@news.povray.org>
Lutz Kretzschmar wrote in message <37f9d4e7.14580615@194.174.214.110>...
>Hi All,
>
>while trying to track down a bug I found that negative scaling can
>make objects disappear and was wondering (not being too well-versed in
>POV) whether this is legal or not:
>
>
>default { pigment { color rgb <1,1,0> }}
>
>union

>  sphere {
>    <-1,0,0>,1
>  }
>  sphere { // Sphere101
>    <1,0,0>,1
>  }
>  cylinder { // Cylndr034
>    <-1,0,0>, <1,0,0>, 0.7
>  }
>  scale 1 // <- Change to -1 and see the spheres disappear
>}
>
>
>light_source
>{
>  0*x // light's position (translated below)
>  color red 1.0  green 1.0  blue 1.0  // light's color
>  translate <20, 40, 50>
>}
>
>camera { location <0,0,6> look_at 0 }


The problem only occurs when scaling by <-1,-1,-1>.  Scaling by <-1,1,1>,
<1,-1,1>, <1,1,-1>, or anything else doesn't cause problems.

Mark


Post a reply to this message

From: Ron Parker
Subject: Re: Strange behaviour?
Date: 6 Oct 1999 20:46:59
Message: <37fbed83@news.povray.org>
On Wed, 6 Oct 1999 01:17:27 -0400, Mark Wagner wrote:
>The problem only occurs when scaling by <-1,-1,-1>.  Scaling by <-1,1,1>,
><1,-1,1>, <1,1,-1>, or anything else doesn't cause problems.

(Crossposted to bugreports)

Ah, now it begins to make sense.  See, when you scale a sphere it 
multiplies the radius and the center by the scale factor unless it
either already has a nonuniform transform in its list or the scale
factor itself is nonuniform; in those two cases it uses the usual,
more sophisticated methods.

Obviously, making the radius negative is a bad thing.  Here's the
fix, in the function Scale_Sphere in spheres.c:

   if (Sphere->Trans == NULL)
   {
     VScaleEq(Sphere->Center, Vector[X]);

-    Sphere->Radius *= Vector[X];
+    Sphere->Radius *= fabs(Vector[X]);
 
     Compute_Sphere_BBox(Sphere);
   }


Post a reply to this message

From: Margus Ramst
Subject: Re: Strange behaviour?
Date: 7 Oct 1999 06:30:02
Message: <37FC75F4.8F7BB1DD@peak.edu.ee>
So why does manual bounding fix the problem?
What happens to the bounding boxes?

Margus

Ron Parker wrote:
> 
> 
> Ah, now it begins to make sense.  See, when you scale a sphere it
> multiplies the radius and the center by the scale factor unless it
> either already has a nonuniform transform in its list or the scale
> factor itself is nonuniform; in those two cases it uses the usual,
> more sophisticated methods.
> 
> Obviously, making the radius negative is a bad thing.  Here's the
> fix, in the function Scale_Sphere in spheres.c:
> 
>    if (Sphere->Trans == NULL)
>    {
>      VScaleEq(Sphere->Center, Vector[X]);
> 
> -    Sphere->Radius *= Vector[X];
> +    Sphere->Radius *= fabs(Vector[X]);
> 
>      Compute_Sphere_BBox(Sphere);
>    }


Post a reply to this message

From: Ron Parker
Subject: Re: Strange behaviour?
Date: 7 Oct 1999 09:08:05
Message: <37fc9b35@news.povray.org>
On Thu, 07 Oct 1999 13:29:08 +0300, Margus Ramst wrote:
>So why does manual bounding fix the problem?
>What happens to the bounding boxes?

I think the negative radius is just fine in the sphere intersection
code, probably because it uses radius squared for its computations 
so as to avoid taking square roots.  The problem must happen because
the bounding box ends up being "backwards" - i.e. having a minimum
corner of <1,1,1> and a size of <-2,-2,-2>.  The bounding code must
not be able to handle that.  Setting a manual bounding volume makes
POV-Ray ignore the automatically calculated bounds.


Post a reply to this message

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