POV-Ray : Newsgroups : povray.general : transforming splines : Re: transforming splines Server Time
1 Aug 2024 04:16:14 EDT (-0400)
  Re: transforming splines  
From: Mike Williams
Date: 3 Apr 2006 12:06:27
Message: <ejaU3DAnfUMEFwrY@econym.demon.co.uk>
Wasn't it Charles C who wrote:
>HI, I've got a 2 part question. I think the short answer will be "no" but I
>haven't found the answer for sure looking on my own. (not sure if this'd be
>better in NewUsers or general):
>
>I was starting on a project where I'll be using splines extensively, and not
>for the usual camera paths or prisms etc.  It'd be useful if rotate, scale
>and translate could be applied directly to a spline.  Say, for instance you
>have a string of Object_A along Spline_A and you want to create a similar
>string of Object_B along Spline_B where Spline_B is a mirrored copy of
>Spline_A.  Is there a simple way to do this example other than keeping
>track of the control points (in an array or whatever)?

Create the string of mirrored Object_B's along Spline_A inside a union
then mirror the whole union. The Object_B's are mirrored twice, so they
come out the right way round, but their positions are only mirrored
once.

You can do the same thing with rotations and other scales. Apply the
inverse transformation to the objects, then apply the required
transformation to the union.


#version 3.6;
global_settings {assumed_gamma 1.0}
camera {location  <0,0,-10> look_at <0,1,0> angle 20}
background {rgb 1}
light_source {<0, 30, -30> color rgb 1}

// ----------------------------------------


#declare Spline_A = function {
   spline {
     natural_spline
     0.0,  < 0.5, 0, 0.0>,
     0.25, < 0.2, 0.5, 0.4>,
     0.5,  < 0.2, 0.6, 0.2>,
     0.75, < 0.4, 1.2, 0.4>,
     1.0,  < 0.0, 2,-0.6>
   }
 }
#declare Object_A = union {
  sphere {0,0.1}
  sphere {x*0.1,0.05}
  pigment {rgb x}
}
#declare Object_B = union {
  box {-0.1,0.1}
  sphere {x*0.15,0.05}
  pigment {rgb y}
}


// The normal copy of the spline with Object_A's
#declare i=0;
#while (i<1)
  object {Object_A translate Spline_A(i)}
  #declare i = i+0.04;
#end

// A mirrored copy of the spline with Object_B's
union {
  #declare i=0;
  #while (i<1)
    object {Object_B scale <-1,0,0> translate Spline_A(i)}
    #declare i = i+0.04;
  #end
  scale <-1,0,0>
}

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

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