POV-Ray : Newsgroups : povray.general : Round_Box with multiple Radii : Re: Round_Box with multiple Radii Server Time
1 Aug 2024 14:30:47 EDT (-0400)
  Re: Round_Box with multiple Radii  
From: Mike Williams
Date: 31 Aug 2005 03:01:53
Message: <oTL2qAAEUVFDFwKb@econym.demon.co.uk>
Wasn't it Rick Measham who wrote:
>I want to create a Round Box, but be able to specify Radii for each 
>corner (or at least for more than a universal setting). I figure this 
>will be an ISO Surface or a mesh (hopefully an ISO surface so it can 
>easily be called in a macro..)

It's possible to create an isosurface that's a linear combination of
f_rounded_box functions with the same box size but different radii.
That's not going to give you total freedom to control the radius at each
corner individually.

The easiest version is where four corners on one end have one radius,
and the four corners on the opposite end have another radius:


#include "functions.inc"
camera { location  <0, 1, -4> look_at <0, 0, 0> angle 25}
light_source {<-100,200,-100> colour rgb 1}

// Outer dimensions of the box
#declare X=0.7;
#declare Y=0.4;
#declare Z=0.7;

// Radius of roundness on the left and right
#declare RL=0.15;
#declare RR=0.05;

isosurface {
  function { 
     f_rounded_box(x,y,z,RL,X,Y,Z) * (X-x) +
     f_rounded_box(x,y,z,RR,X,Y,Z) * (x+X)
   }
   max_gradient 1.5
   contained_by{box {-<X,Y,Z>*1.01,<X,Y,Z>*1.01}}
   pigment {rgb 1}
}

In the above case, all the corners on the left have radius RL and all
those on the right have radius RR.

When we extend this to perform linear combinations along the three axes,
the radius that gets used at the top-left-front corner is some sort of
combination of RL, RT and RF. (I'd expected it to be the average of RL,
RT and RF, but that doesn't seem to be the case.)

  function { 
     f_rounded_box(x,y,z,RL,X,Y,Z) * (X-x) +
     f_rounded_box(x,y,z,RR,X,Y,Z) * (x+X) +
     f_rounded_box(x,y,z,RB,X,Y,Z) * (Y-y) +
     f_rounded_box(x,y,z,RT,X,Y,Z) * (y+Y) +
     f_rounded_box(x,y,z,RF,X,Y,Z) * (Z-z) +
     f_rounded_box(x,y,z,RBK,X,Y,Z) * (z+Z)
   }

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

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