POV-Ray : Newsgroups : povray.general : transforming splines Server Time
29 Nov 2024 05:33:41 EST (-0500)
  transforming splines (Message 1 to 7 of 7)  
From: Charles C
Subject: transforming splines
Date: 3 Apr 2006 11:20:01
Message: <web.44313c84e2ecfab7b160ffde0@news.povray.org>
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)?

Also, since as of v3.6 there's the parse warning message that splines are
"experimental" does anybody know what changes (if any) might be in the
works?

Thanks,

Charles


Post a reply to this message

From: Jim Charter
Subject: Re: transforming splines
Date: 3 Apr 2006 11:50:50
Message: <4431445a$1@news.povray.org>
Charles C 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)?
>
> 

I think you'll have to transform the control points not the spline.  The 
transform itself can be predefined, then use vtransform.  It may or may 
not advantage you to store the points in an array.


Post a reply to this message

From: Mike Williams
Subject: Re: transforming splines
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

From: Jim Charter
Subject: Re: transforming splines
Date: 3 Apr 2006 12:20:01
Message: <44314b31$1@news.povray.org>
#include "transforms.inc"
#macro MarkOrigin (Rad)  //mark origin
   cylinder { -100*y 0*y Rad pigment {rgb .5} finish {ambient .8}}
   cylinder { -100*z 0*z Rad pigment {rgb .5} finish {ambient .8}}
   cylinder { -100*x 0*x Rad pigment {rgb .5} finish {ambient .8}}
   cylinder {  0*y 100*y Rad pigment {rgb <0,1,0>} finish {ambient .8}}
   cylinder {  0*z 100*z Rad pigment {rgb <0,0,1>} finish {ambient .8}}
   cylinder {  0*x 100*x Rad pigment {rgb <1,0,0>} finish {ambient .8}} 


#end
#macro ShowSpline ( TheSpline, TheRadius, Grain, TheColor  )
         union {
                 #local i=0;#while(i<Grain)
                         cylinder {
                                 TheSpline((i+1)/Grain)+.00001,
                                 TheSpline(i/Grain),
                                 TheRadius
                                 pigment { rgb TheColor }
                                 finish { ambient 1 }
                         }
                         sphere {
                                 TheSpline(i/Grain),
                                 TheRadius
                                 pigment { rgb TheColor  }
                                 finish { ambient 1 }
                         }
                 #local i=i+1;#end

         }
#end

MarkOrigin ( .005 )

#local P0 = <-1,0,0>;
#local P1 = <0,1,0>;
#local P2 = <1,0,0>;

#local Trans =
transform {
         //
};

#local Spl =
spline { natural_spline
         0/2 vtransform ( P0, Trans )
         1/2 vtransform ( P1, Trans )
         2/2 vtransform ( P2, Trans )
};

ShowSpline ( Spl, .01, 100, <1,0,1> )

#local Trans =
transform {
         rotate z*30
         translate <1,1,0>
};

#local Spl =
spline { natural_spline
         0/2 vtransform ( P0, Trans )
         1/2 vtransform ( P1, Trans )
         2/2 vtransform ( P2, Trans )
};

ShowSpline ( Spl, .01, 100, <1,1,0> )

camera {
   location  vrotate ( <0, 0, -10>, <   5,  0, 0> )
   look_at   vrotate ( <0, 0,   0>, <   0, 0, 0> )
   right     x*image_width/image_height
   angle 32
}


Post a reply to this message

From: Trevor G Quayle
Subject: Re: transforming splines
Date: 3 Apr 2006 13:00:00
Message: <web.443153a373c7aea86c4803960@news.povray.org>
"Charles C" <nomail@nomail> 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)?
>
> Also, since as of v3.6 there's the parse warning message that splines are
> "experimental" does anybody know what changes (if any) might be in the
> works?
>
> Thanks,
>
> Charles

have a look at "vaxis_rotate(A,B,F)" in "3.2.1.4.5  Functions" of the help
file.  Should be able to help you.


-tgq


Post a reply to this message

From: Charles C
Subject: Re: transforming splines
Date: 4 Apr 2006 11:15:01
Message: <web.44328d0473c7aea8b160ffde0@news.povray.org>
Thanks for the well thought out and quick replies!  I was at work when I
posted the question and later when I was at home I tried to reply after
rendering those samples... Unfortunately the webserver doesn't seem to
always like me and my high-latency connection (that's my guess anyway).  It
always prompts me for my login again after I type the correct password, or
tells me I typed the wrong password if in fact I did so.

Anyway, it looks like I probably will be storing the original control points
of the spline in an array afterall so that it can be modified in arbitrary
ways before use.

From: Mike Williams
>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.

Thanks Mike.  I hadn't thought about this.


From: Jim Charter:
> I think you'll have to transform the control points not the spline.  The
> transform itself can be predefined, then use vtransform.  It may or may
> not advantage you to store the points in an array.

I hadn't realised that a transform could be pre-defined.  That sounds a lot
more convienient. Thanks


From: Trevor G Quayle:
> have a look at "vaxis_rotate(A,B,F)" in "3.2.1.4.5  Functions" of the help
> file.  Should be able to help you.

Actually I knew about this one... It's been very helpful for articulating
things!


Post a reply to this message

From: Jim Charter
Subject: Re: transforming splines
Date: 4 Apr 2006 12:42:20
Message: <4432a1ec$1@news.povray.org>
Charles C wrote:

> 
> I hadn't realised that a transform could be pre-defined.  That sounds a lot
> more convienient. Thanks
> 
> 
Welcome.
After re-reading your post I also remembered this that I sometimes use:

Say I wanted to position some points along a spline, (say ultimately to 
position fish bones along a fish's sinuous spine.)  The Reorient_Trans 
macro comes to mind, but it is used for objects and I just want the points.

You can do something like this:

#macro Reorient(Axis)
         transform { Reorient_Trans ( x, Axis )}
#end

then with
spline Spl defined:


vtransform ( P, Reorient( Spl(clock)-Spl(clock-delta) )


Post a reply to this message

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