POV-Ray : Newsgroups : povray.binaries.images : Friday Afternoon Doodle : Re: Friday Afternoon Doodle Server Time
28 May 2024 09:25:41 EDT (-0400)
  Re: Friday Afternoon Doodle  
From: Chris R
Date: 7 Mar 2022 14:00:00
Message: <web.6226560215dda32bd6fc33af5cc1b6e@news.povray.org>
"Chris R" <car### [at] comcastnet> wrote:
> "Kenneth" <kdw### [at] gmailcom> wrote:
> > "Chris R" <car### [at] comcastnet> wrote:
> > >
> > > So I've been playing around with shapes extruded along one of the axes, by
> > > changing the rounding parameter and the scaling parameters on the other two
> > > axes, as well as translating the center of the rounded box along those two other
> > > axes in various ways, including linear interpolation, spline interpolation, and
> > > various other functions.
> > >
> > > This is the one where the scale decreases linearly from bottom to top, the
> > > rounding factor decreases linearly from bottom to top, and the x and z centers
> > > of the box are translated using sin(y*2*pi/height) and cos(y*2*pi/height).
> > >
> >
> > That's a nice result, and a clever use of functions. And gold colors! I assume
> > that this is just one function-object, not a 'combination' of several function
> > shapes?
> >
> > I experimented with function-based isosurfaces years ago, but have forgotten
> > some of the finer points, like how to 'taper' an object (like you did in y.) But
> > I happened to be playing around with this same kind of technique this week! I
> > can make a nice sine-wave shape, but what is the trick for getting the shape to
> > taper or scale so nicely? IIRC, it is something relatively simple-- but I
> > can't remember what :-(
>
> Here's a pretty simple example with linear tapering.  I did something similar
> with the image above, but embedded the tapering in functions instead.
>
> #macro TaperedBox(SizeBase,SizeTop,RoundingBase,RoundingTop,Height)
>    #local _xSlope = (SizeTop.x - SizeBase.x)/(2*Height);
>    #local _zSlope = (SizeTop.z - SizeBase.z)/(2*Height);
>    #local _rndSlope = (RoundingTop - RoundingBase)/Height;
>    #local _xScaleBase = SizeBase.x/2;
>    #local _zScaleBase = SizeBase.z/2;
>    #local _xScaleFn = function(l) {
>       _xScaleBase + _xSlope*l
>    }
>    #local _zScaleFn = function(l) {
>       _zScaleBase + _ySlope*l
>    }
>    #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,
> _zScaleFn(y+_sy))
>    }
>
>    #local _maxx = max(SizeBase.x,SizeTop.x)/2;
>    #local _maxz = max(SizeBase.z,SizeTop.z)/2;
>    #local _lbounds = -<_maxx, _sy, _maxz>;
>    #local _ubounds = <_maxx, _sy, _maxz>;
>
>    #local _shape = isosurface {
>       function {
>          _shapeFn(x,y,z)
>       }
>       threshold 0
>       contained_by { box { _lbounds, _ubounds } }
>    }
>
>    #undef _shapeFn
>    #undef _rndFn
>    #undef _zScaleFn
>    #undef _xScaleFn
>
>    _shape
>
> #end
>
> TaperedBox(<2,2>, <1,1>, 0.2, 0.1, 2)
>
> I have purposefully, pedantically, broken things out, because it helps me
> remember why I wrote the code when I go back to it months down the line.
>
> This should give you a truncated pyramid with a rounded bottom, rounded edges,
> with the rounding decreasing as you move up the pyramid.
>
> I use the RC3 Metal macros to create the gold texture.
>
>
> -- Chris R.

Sorry, transcription error, yScaleBase should have been zScaleBase in _zScaleFn

-- Chris R.


Post a reply to this message

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