POV-Ray : Newsgroups : povray.binaries.images : Friday Afternoon Doodle : Re: Friday Afternoon Doodle Server Time
16 Apr 2024 20:32:58 EDT (-0400)
  Re: Friday Afternoon Doodle  
From: Kenneth
Date: 7 Mar 2022 20:20:00
Message: <web.6226ad3b15dda32b4cef624e6e066e29@news.povray.org>
"Chris R" <car### [at] comcastnet> wrote:
> Here's a pretty simple example with linear tapering.  I did something similar
> with the image above, but embedded the tapering in functions instead.
> [code snip]
> Sorry, transcription error, yScaleBase should have been zScaleBase in _zScaleFn

Thanks! That's really interesting (and a bit more complex than I thought, ha.)
Now I can play around, to see what I can muck up! :-O

I had to make some minor changes to your code to get it to run-- replacing some
z's with y's -- probably because the macro call uses two-part vectors, like
<2,2> for the 'SizeBase' etc. So that would be like <x,y> (or even <u,v>)
instead of <x,z>... which POV-ray chokes on ;-) At least in Windows.

I've attached my own trial image... just as a sanity check, to make sure I'm
seeing what you intended!

BTW, there are a few interesting pieces of your code that I'm clueless about, as
to what they mean and how they work. Example:
      #local _xScaleFn = function(l)
      _xScaleBase + _xSlope*l

That's a lower-case 'L'. I'm familiar with the typical x (or y or z) use in a
function-- which AFAIU usually represent spatial axes--  but I have never used
just a 'generic' letter as a substitute. Could you briefly explain what that
means, in the context of your code?

Anyway, thanks again for the example!

#include "functions.inc"

#macro TaperedBox(SizeBase,SizeTop,RoundingBase,RoundingTop,Height)
   #local _xSlope = (SizeTop.x - SizeBase.x)/(2*Height);
  // #local _zSlope = (SizeTop.z - SizeBase.z)/(2*Height); // [ORIGINAL]
   #local _zSlope = (SizeTop.y - SizeBase.y)/(2*Height); // changed both to y
   #local _rndSlope = (RoundingTop - RoundingBase)/Height;
   #local _xScaleBase = SizeBase.x/2;
  // #local _zScaleBase = SizeBase.z/2; // [ORIGINAL]
   #local _zScaleBase = SizeBase.y/2; // changed to y
   #local _xScaleFn = function(l) {
      _xScaleBase + _xSlope*l
   #local _zScaleFn = function(l) {
    //  _yScaleBase + _ySlope*l   // [ORIGINAL]
        _zScaleBase + _zSlope*l // [update]
   #local _rndFn = function(l) {
      RoundingBase + _rndSlope*l
   #local _sy = Height/2;
   #local _shapeFn = function(x,y,z) {
      f_rounded_box(x, y, z, _rndFn(y+_sy), _xScaleFn(y+_sy), _sy,

   #local _maxx = max(SizeBase.x,SizeTop.x)/2;
  // #local _maxz = max(SizeBase.z,SizeTop.z)/2; // [ORIGINAL]
   #local _maxz = max(SizeBase.y,SizeTop.y)/2; // changed both to y
   #local _lbounds = -<_maxx, _sy, _maxz>;
   #local _ubounds = <_maxx, _sy, _maxz>;

   #local _shape = isosurface {
      function {
      threshold 0
      contained_by { box { _lbounds, _ubounds } }

   #undef _shapeFn
   #undef _rndFn
   #undef _zScaleFn
   #undef _xScaleFn



TaperedBox(<2,2>, <1,1>, 0.2, 0.1, 2)

Post a reply to this message

Download 'isosurface_tapering_example_1.jpg' (10 KB)

Preview of image 'isosurface_tapering_example_1.jpg'


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