POV-Ray : Newsgroups : povray.beta-test : Filling in T values in splines Server Time
30 Jul 2024 06:26:27 EDT (-0400)
  Filling in T values in splines (Message 10 to 19 of 39)  
<<< Previous 9 Messages Goto Latest 10 Messages Next 10 Messages >>>
From: Rune
Subject: Re: Filling in T values in splines
Date: 24 Feb 2002 07:26:16
Message: <3c78dbe8@news.povray.org>
Hey, it just occurred to me that this syntax could be extended with other
options. Imagine the following:

#declare Spline =
spline {
   Spline_Type(Cubic_Spline)
   Spline_Points(7)
   Spline_Speed(Constant)

   SCP( 0.0, <0,1,2>)
   SCP(   x, <1,5,0>)
   SCP(   x, <4,1,0>)
   SCP(   x, <0,2,1>)
   SCP(   x, <0,0,1>)
   SCP(   x, <6,5,4>)
   SCP( 2.0, <4,3,2>)

   Spline_End()
}

I think this is beginning to be interesting! I hope you agree that the
approach shown here would fit well in the official include files?

Rune
--
3D images and anims, include files, tutorials and more:
Rune's World:    http://rsj.mobilixnet.dk (updated Feb 16)
POV-Ray Users:   http://rsj.mobilixnet.dk/povrayusers/
POV-Ray Webring: http://webring.povray.co.uk


Post a reply to this message

From: Warp
Subject: Re: Filling in T values in splines
Date: 24 Feb 2002 07:27:55
Message: <3c78dc4b@news.povray.org>
Rune <run### [at] mobilixnetdk> wrote:
> #declare Spline =
> spline {
>    cubic_spline
>    Spline_Points(7)

>    SCP( 0.0, <0,1,2>)
>    SCP(   x, <1,5,0>)
>    SCP(   x, <4,1,0>)
>    SCP( 0.9, <0,2,1>)
>    SCP( 1.0, <0,0,1>)
>    SCP(   x, <6,5,4>)
>    SCP( 2.0, <4,3,2>)

>    Spline_End()
> }

  That would be better than nothing.
  Of course there are two things that are a bit bothering: You have to
specify the number of points at the beginning (as always with arrays) and
you have to write extra text ('SCP(...)' and those x's), but I think those
are things that can't be helped currently.

  By the way, it could also be a good idea to add another macro:

#declare Spline =
  spline
  { cubic_spline
    Even_Spline_Points(array[5]{<1,2,3><4,5,6><7,8,9><10,11,12><13,14,15>})
  }

or something similar.

-- 
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -


Post a reply to this message

From: Warp
Subject: Re: Filling in T values in splines
Date: 24 Feb 2002 07:29:30
Message: <3c78dca9@news.povray.org>
Rune <run### [at] mobilixnetdk> wrote:
>    Spline_Type(Cubic_Spline)

  I don't understand the reason for this one.

-- 
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -


Post a reply to this message

From: ingo
Subject: Re: Filling in T values in splines
Date: 24 Feb 2002 07:46:46
Message: <Xns91BF8C7EEDC76seed7@povray.org>
in news:3c78dc4b@news.povray.org Warp wrote:

> or something similar.
> 

Us it as you want it.

---%<------%<---
// The macro allways expects one point
// before t=0 and one after t=1, also for linear splines.
// Use: #declare SPL=BuildSpline(ArrayIdentifiers, "string")
// where string is C|c|L|l|Q|q

#macro BuildSpline(Arr, SplType)
   #local Ds=dimension_size(Arr,1);
   #local Asc=asc(strupr(SplType));
   #if(Asc!=67 & Asc!=76 & Asc!=81) 
      #local Asc=76;
      #debug "\nWrong spline type defined (C/c/L/l/Q/q), using default 
linear_spline\n"
   #end
   spline {
      #switch (Asc)
         #case (67) //C  cubic_spline
            cubic_spline
         #break
         #case (76) //L  linear_spline
            linear_spline
         #break
         #case (81) //Q  Quadratic_spline
            quadratic_spline
         #break
      #end
      #local Add=1/((Ds-2)-1);
      #local J=0-Add;
      #local I=0;
      #while (I<Ds)
         J 
         Arr[I]
         #local I=I+1;
         #local J=J+Add;
      #end
   }      
#end
---%<------%<---


Post a reply to this message

From: Warp
Subject: Re: Filling in T values in splines
Date: 24 Feb 2002 08:35:58
Message: <3c78ec3d@news.povray.org>
I think that it would be better if the macro just created the points, not
the spline itself.

spline { cubic_spline MakeThePoints(whatever) }

-- 
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}//  - Warp -


Post a reply to this message

From: Rune
Subject: Re: Filling in T values in splines
Date: 24 Feb 2002 08:41:29
Message: <3c78ed89$1@news.povray.org>
"Warp" wrote:
> Rune wrote:
> >    Spline_Type(Cubic_Spline)
>
>   I don't understand the reason for this one.

More advanced macro options such as constant speed (I think that's the same
as you call even spline points) will need to know the spline type in order
to create optimal results. It also opens up the possibility of introducing
new spline types that the macros fakes using the existing spline types.

Rune
--
3D images and anims, include files, tutorials and more:
Rune's World:    http://rsj.mobilixnet.dk (updated Feb 16)
POV-Ray Users:   http://rsj.mobilixnet.dk/povrayusers/
POV-Ray Webring: http://webring.povray.co.uk


Post a reply to this message

From: Rune
Subject: Re: Filling in T values in splines
Date: 24 Feb 2002 09:43:59
Message: <3c78fc2f@news.povray.org>
"Warp" wrote:
>   That would be better than nothing.

Well, that's something.

>   Of course there are two things that are a bit bothering:
> You have to specify the number of points at the beginning

Actually you can just make the number plenty large and then you don't have
to worry about changing it every time you add a new point. As the array will
be bigger it will require slightly more ressources, but nothing of
importance. The point is that you don't get an error and that it gives the
same result.

> and you have to write extra text ('SCP(...)' and those x's)

Yes...

> #declare Spline =
>   spline
>   { cubic_spline
>
Even_Spline_Points(array[5]{<1,2,3><4,5,6><7,8,9><10,11,12><13,14,15>})
>   }
>
> or something similar.

Do you mean evenly distributed T values or evenly distributed points of the
spline. The first is very easy while the second is slightly more tricky, but
I intent to make support for both.

Rune
--
3D images and anims, include files, tutorials and more:
Rune's World:    http://rsj.mobilixnet.dk (updated Feb 16)
POV-Ray Users:   http://rsj.mobilixnet.dk/povrayusers/
POV-Ray Webring: http://webring.povray.co.uk


Post a reply to this message

From: Christopher James Huff
Subject: Re: Filling in T values in splines
Date: 24 Feb 2002 10:03:31
Message: <chrishuff-C72E52.10032224022002@netplex.aussie.org>
In article <3c78ec3d@news.povray.org>, Warp <war### [at] tagpovrayorg> 
wrote:

>   I think that it would be better if the macro just created the points, not
> the spline itself.
> 
> spline { cubic_spline MakeThePoints(whatever) }

And you should be able to set the beginning and end T values. That way, 
you could paste the spline data into an existing spline.

-- 
Christopher James Huff <chr### [at] maccom>
POV-Ray TAG e-mail: chr### [at] tagpovrayorg
TAG web site: http://tag.povray.org/


Post a reply to this message

From: Warp
Subject: Re: Filling in T values in splines
Date: 24 Feb 2002 11:02:48
Message: <3c790ea8@news.povray.org>
Rune <run### [at] mobilixnetdk> wrote:
> Do you mean evenly distributed T values or evenly distributed points of the
> spline.

  I meant evenly distributed T values (ie. just interpolate them between
0 and 1).

  (Of course a more advanced option could make the macro to interpolate
the T values non-linearly.)

  As for evenly-distributed points along the spline, I think that the only
feasible way of doing that is to make a macro which returns points for the
given spline (in the same way as the Colefax include does). Of course this
will make it a bit slow (because it has to approximate by sampling points on
the spline).

-- 
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}//  - Warp -


Post a reply to this message

From: Rune
Subject: Re: Filling in T values in splines
Date: 24 Feb 2002 11:49:45
Message: <3c7919a9@news.povray.org>
"Warp" wrote:
>   (Of course a more advanced option could make
> the macro to interpolate the T values non-linearly.)

I don't think I'll implement that. With both the T values and the points
being non-linearly interpolated, I'm not even able to figure out in my head
in what way the results would be different. And non-linearly interpolation
of strongly varying T values could cause the T values to go backwards at
times, which would mess up everything.

>   As for evenly-distributed points along the spline,
> I think that the only feasible way of doing that is
> to make a macro which returns points for the given
> spline (in the same way as the Colefax include does).

I've done that before and it's not that slow. However, a solution I'd like
to try is to return a new spline which has many more control points than the
original and where those control points are arranged to give constant speed.
This too is just an approximation, but it would be faster, as the
calculations would only need to be done once, and it could also be made
completely transparent to the user, who will call the spline like normal,
without the need for macros once the spline has been created.

Rune
--
3D images and anims, include files, tutorials and more:
Rune's World:    http://rsj.mobilixnet.dk (updated Feb 16)
POV-Ray Users:   http://rsj.mobilixnet.dk/povrayusers/
POV-Ray Webring: http://webring.povray.co.uk


Post a reply to this message

<<< Previous 9 Messages Goto Latest 10 Messages Next 10 Messages >>>

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