POV-Ray : Newsgroups : povray.bugreports : min_extent () & max_extent () : Re: min_extent () & max_extent () Server Time
15 May 2024 20:30:19 EDT (-0400)
  Re: min_extent () & max_extent ()  
From: clipka
Date: 8 Apr 2009 06:50:01
Message: <web.49dc7c212b53252c8b4957a40@news.povray.org>
"Stephen Klebs" <skl### [at] gmailcom> wrote:
> /*
> Don't know if this is a known bug but the functions min_extent()
> and max_extent() are not correct with cylinders and cones whose
> ends are not parallel to an axis. Have not tested in 3.7.
> Works correctly when rotated and translated into position.
> */

This is actually not a bug, but merely a case of "doesn't work as I expected".

According to the documentation, min_extent() and max_extent() functions return
the dimensions of the bounding box - but this is *not* necessarily the smallest
extents the object might fit in.

If you add the following statements to your scene, you will see that both boxes
properly bound the respective cylinder (albeit not optimally in case of
Cylinder2):

box { min_extent (Cylinder1), max_extent (Cylinder1)
  pigment { color rgbt <1,0,0,0.5> }
}

box { min_extent (Cylinder2), max_extent (Cylinder2)
  pigment { color rgbt <0,1,0,0.5> }
}

This has something to do with the way cylinders are represented internally, and
the way the bounding box is computed: All cylinders are actually
cylinder{<-1,-1,0>,<1,1,1>},1}, equipped with a base transformation that
orients and resizes the cylinder as desired. Note rotating the cylinder about
its axis will not hurt, and the algorithm to compute the transformation may
actually do that for the sake of code simplicity.

Enter bounding box magic. Like many other objects, a cylinder's bounding box is
computed in two stages:
- Build a "prototype" bounding box around the untransformed object
- Build a final bounding box around the transformed prototype box

It seems that in your particular case, the base transformation includes not only
a rotation around the Z axis, but also around the cylinder's axis (by something
close to 45 degrees). Although it does not affect the geometry in any way, it
does affect the orientation of the "prototype" bounding box, and therefore the
extent of the final bounding box.


Post a reply to this message

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