POV-Ray : Newsgroups : povray.general : questions on parametric objects and 3d splines : Re: questions on parametric objects and 3d splines Server Time
3 Aug 2024 10:17:22 EDT (-0400)
  Re: questions on parametric objects and 3d splines  
From: Mike Williams
Date: 16 Mar 2004 02:55:40
Message: <mlbRVDA4KrVAFwkh@econym.demon.co.uk>
Wasn't it lars petter who wrote:
>Hello!
>
>At school, we're developing a modelling tool that will generate shapes such
>as bezier curves, parabolas, ellipses and such in povray.
>
>In the tool we have the parametrisised functions for all the shapes, so when
>it comes to the Pov-Ray script-generation, we're thinking about using the
>Parametric Object.
>
>However, our shapes are supposed to have thickness and a height as well, and
>the Pov-Ray online documentation says; "The parametric object is not a solid
>object it is "hollow", like a thin shell."
>
>So then we're wondering if there is some way to make these objects have a
>thickness as well.. Like one does with the isosurfaces, just subtract the
>thickness from the equation or something...?
>
>The perfect solution however, would be that something like this can be done:
>http://hovedprosjekter.hig.no/v2004/data/gruppe11/param_obj.gif
>
>A rectangle is swept along a parametrisised 3d spline to construct the solid
>object.. is this possible?

All objects in POV are "hollow" in the sense meant in that part of the
documentation. The only difference with parametric objects is that many
sets of parametric equations result in surfaces that are open.

I guess that you're only thinking of using the "parametric object"
because you're working with "parameterisised functions" and they sound a
bit like they might be the same sort of thing. The tricky bit is going
to be that the "parameterisised functions" that create your curves are
likely to be three one-dimensional functions, whereas the POV parametric
object requires three two-dimensional functions.

Do take a look at the "bent prism" and the "sweepspline" in my
isosurface tutorial. 
<http://www.econym.demon.co.uk/isotut/more.htm>
<http://www.econym.demon.co.uk/isotut/splines.htm>

but you might be better off just doing exactly what is drawn in that gif
image you mentioned. Draw a large number of rounded rectangles that
follow the curve. If you draw them so that they are closer than a pixel
then they look like a continuous shape.

Here's some code that does that. Note the "Turn" parameter which
determines whether the rectangles are placed perpendicular to the path
or perpendicular to the z-axis.

#version 3.5;
global_settings {assumed_gamma 1.0}
camera {location  <0,0,-10> look_at <0,0,0> angle 30}
background {rgb 1}
light_source {<30, 100, -30> color rgb 1}
#include "transforms.inc"

// The "spline" parameters
#declare fx=function(u){sin(u)+cos(2*u)}
#declare fy=function(u){sin(3*u)}
#declare fz=function(u){u}

#declare Height=0.5;            // Rectangle Height
#declare Width=0.3;             // Rectangle Width
#declare Radius=0.05;           // Rectangle roundness
#declare Step = Radius/50;      // Make this smaller for larger images
                                // and smaller for quick tests

#declare Turn=1;             // set to 0 for the Rectangle to not turn

#declare Rect = union {
  sphere {<Width,Height,0>,Radius}
  sphere {<-Width,Height,0>,Radius}
  sphere {<-Width,-Height,0>,Radius}
  sphere {<Width,-Height,0>,Radius}
  cylinder {<Width,Height,0><-Width,Height,0>,Radius}
  cylinder {<-Width,Height,0><-Width,-Height,0>,Radius}
  cylinder {<-Width,-Height,0><Width,-Height,0>,Radius}
  cylinder {<Width,-Height,0><Width,Height,0>,Radius}
  pigment {rgb 1}
}

#declare E=0.00001;
#declare i=-1;
#while (i<1)
  //Use this to show the track of the "spline"
  //sphere {<fx(i),fy(i),fz(i)>,0.01 pigment {rgb x}}
  
  #if (Turn)
    // calculate the direction
    #declare D=<fx(i),fy(i),fz(i)> - <fx(i-E),fy(i-E),fz(i-E)>;
    // sweep out with turning rounded rectangle
    object {Rect
      transform {Reorient_Trans(z,D)}
      translate <fx(i),fy(i),fz(i)>
    }
  #else
    // sweep out with rounded rectangle
    object {Rect translate <fx(i),fy(i),fz(i)>}
  #end
  #declare i=i+Step;
#end

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

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