POV-Ray : Newsgroups : povray.general : Length along a spline Server Time
15 Oct 2026 12:38:08 EDT (-0400)
  Length along a spline (Message 1 to 13 of 13)  
From: Gail Shaw
Subject: Length along a spline
Date: 17 Oct 2001 03:42:40
Message: <3bcd3670@news.povray.org>
I'm trying to write a macro to create a chain that follows a spline and I've
run
into a problem. As far as I can tell there is no way to get the value of a
spline
at equal distances along it.

Does anyone know of a way to place objects at equal distances along
a spline, short of trial and error?

Gail
--
*************************************************************************
* gsh### [at] monotixcoza                *   Step into the abyss,           *
* http://www.rucus.ru.ac.za/~gail/   *   and let go.          Babylon 5 *
*************************************************************************
* Just think of me as the storm before the calm     Magic: The Gathering*
*************************************************************************


Post a reply to this message

From: Nekar Xenos
Subject: Re: Length along a spline
Date: 17 Oct 2001 04:02:28
Message: <3bcd3b14@news.povray.org>
I guess you'd need to know what the mathematical formula is for the spline. If
you have that you can test for an intersection with a sphere having a diameter
the same as the distance you want. Start with the sphere centre at the one end
of the spline and then move the centre to the result you get each time. You'll
should get 2 values each time, so you'll have to check which is the correct one.
One of the two values should be the same as the one before the previous one.

I hope this is understandable. Unfortunately I don't know the mathematical
formula for a spline. It's probably in the docs...

- Nekar

"Gail Shaw" <gsh### [at] monotixcoza> wrote in message
news:3bcd3670@news.povray.org...
> I'm trying to write a macro to create a chain that follows a spline and I've
> run
> into a problem. As far as I can tell there is no way to get the value of a
> spline
> at equal distances along it.
>
> Does anyone know of a way to place objects at equal distances along
> a spline, short of trial and error?
>
> Gail
> --
> *************************************************************************
> * gsh### [at] monotixcoza                *   Step into the abyss,           *
> * http://www.rucus.ru.ac.za/~gail/   *   and let go.          Babylon 5 *
> *************************************************************************
> * Just think of me as the storm before the calm     Magic: The Gathering*
> *************************************************************************
>
>


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.282 / Virus Database: 150 - Release Date: 2001/09/25


Post a reply to this message

From: Nekar Xenos
Subject: Re: Length along a spline
Date: 17 Oct 2001 04:15:34
Message: <3bcd3e26@news.povray.org>
Thinking about it, it might be a bit more complicated. If you have sharp bends
in the spline, you could get more than two results.

- Nekar

"Nekar Xenos" <j-p### [at] citywalkcoza> wrote in message
news:3bcd3b14@news.povray.org...
> I guess you'd need to know what the mathematical formula is for the spline. If
> you have that you can test for an intersection with a sphere having a diameter
> the same as the distance you want. Start with the sphere centre at the one end
> of the spline and then move the centre to the result you get each time. You'll
> should get 2 values each time, so you'll have to check which is the correct
one.
> One of the two values should be the same as the one before the previous one.
>
> I hope this is understandable. Unfortunately I don't know the mathematical
> formula for a spline. It's probably in the docs...
>
> - Nekar
>
> "Gail Shaw" <gsh### [at] monotixcoza> wrote in message
> news:3bcd3670@news.povray.org...
> > I'm trying to write a macro to create a chain that follows a spline and I've
> > run
> > into a problem. As far as I can tell there is no way to get the value of a
> > spline
> > at equal distances along it.
> >
> > Does anyone know of a way to place objects at equal distances along
> > a spline, short of trial and error?
> >
> > Gail
> > --
> > *************************************************************************
> > * gsh### [at] monotixcoza                *   Step into the abyss,           *
> > * http://www.rucus.ru.ac.za/~gail/   *   and let go.          Babylon 5 *
> > *************************************************************************
> > * Just think of me as the storm before the calm     Magic: The Gathering*
> > *************************************************************************
> >
> >
>
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.282 / Virus Database: 150 - Release Date: 2001/09/25
>
>


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.282 / Virus Database: 150 - Release Date: 2001/09/25


Post a reply to this message

From: Kari Kivisalo
Subject: Re: Length along a spline
Date: 17 Oct 2001 07:05:34
Message: <3BCD6601.2B58E441@engineer.com>
Gail Shaw wrote:
>
> Does anyone know of a way to place objects at equal distances along
> a spline, short of trial and error?

My lspline3 include implements natural cubic splines where the
parameter points linearly along the length of the spline.

http://www.pp.htv.fi/kkivisal/lspline3.zip


_____________
Kari Kivisalo


Post a reply to this message

From: Gail Shaw
Subject: Re: Length along a spline
Date: 17 Oct 2001 07:37:07
Message: <3bcd6d63@news.povray.org>
"Kari Kivisalo" <ray### [at] engineercom> wrote in message
news:3BCD6601.2B58E441@engineer.com...
>
> My lspline3 include implements natural cubic splines where the
> parameter points linearly along the length of the spline.
>

Thanks, I'll take a look at that

Gail
--
*************************************************************************
* gsh### [at] monotixcoza                *   Step into the abyss,           *
* http://www.rucus.ru.ac.za/~gail/   *   and let go.          Babylon 5 *
*************************************************************************
* Just think of me as the storm before the calm     Magic: The Gathering*
*************************************************************************


Post a reply to this message

From: Warp
Subject: Re: Length along a spline
Date: 17 Oct 2001 14:08:09
Message: <3bcdc908@news.povray.org>
I would use Colefax's spline macros. It does that and a lot more.

http://www.geocities.com/ccolefax/spline/index.html

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


Post a reply to this message

From: JRG
Subject: Re: Length along a spline
Date: 17 Oct 2001 15:37:26
Message: <3bcdddf6$1@news.povray.org>
There are times when the simplest choice is not the most exciting. I'm quite
sure that Gail does know Chris' fantastic macros (or at least he could have
easily found them, just had he wanted)... I guess you know what I mean :)

--
Jonathan.

"Warp" <war### [at] tagpovrayorg> ha scritto nel messaggio
news:3bcdc908@news.povray.org...
>   I would use Colefax's spline macros. It does that and a lot more.
>
> http://www.geocities.com/ccolefax/spline/index.html
>
> --
> #macro N(D,I)#if(I<6)cylinder{M()#local D[I]=div(D[I],104);M().5,2pigment{
> rgb M()}}N(D,(D[I]>99?I:I+1))#end#end#macro M()<mod(D[I],13)-6,mod(div(D[I
> ],13),8)-3,10>#end blob{N(array[6]{11117333955,
> 7382340,3358,3900569407,970,4254934330},0)}//                     - Warp -


Post a reply to this message

From: Trevor Quayle
Subject: Re: Length along a spline
Date: 17 Oct 2001 15:46:02
Message: <3bcddffa$1@news.povray.org>
In 3.5, you would define a spline as follows:

#declare MySpline =
spline {cubic_spline
    -.25, <0,0,-1>
    0.00, <1,0,0>
    0.25, <0,0,1>
    0.50, <-1,0,0>
    0.75, <0,0,-1>
    1.00, <1,0,0>
    1.25, <0,0,1>
  }

And implement it using MySpline(val)

Does val not indicate the position along the spline, i.e, 0.1 would be 10%
along the length of the spline etc.?

-tgq


Post a reply to this message

From: Marc-Hendrik Bremer
Subject: Re: Length along a spline
Date: 17 Oct 2001 15:50:37
Message: <3bcde10d@news.povray.org>
Trevor Quayle schrieb in Nachricht <3bcddffa$1@news.povray.org>...

>Does val not indicate the position along the spline, i.e, 0.1 would be 10%
>along the length of the spline etc.?


No.


Post a reply to this message

From: Trevor Quayle
Subject: Re: Length along a spline
Date: 17 Oct 2001 15:58:54
Message: <3bcde2fe@news.povray.org>
What does it mean then?  Ic ouldn't find it in the docs.

-tgq


"Marc-Hendrik Bremer" <Mar### [at] t-onlinede> wrote in message
news:3bcde10d@news.povray.org...
> Trevor Quayle schrieb in Nachricht <3bcddffa$1@news.povray.org>...
>
> >Does val not indicate the position along the spline, i.e, 0.1 would be
10%
> >along the length of the spline etc.?
>
>
> No.
>


Post a reply to this message

From: Gail Shaw
Subject: Re: Length along a spline
Date: 18 Oct 2001 02:22:00
Message: <3bce7508@news.povray.org>
"Trevor Quayle" <Tin### [at] hotmailcom> wrote in message
news:3bcddffa$1@news.povray.org...
> In 3.5, you would define a spline as follows:
>
> #declare MySpline =
> spline {cubic_spline
>     -.25, <0,0,-1>
>     0.00, <1,0,0>
>     0.25, <0,0,1>
>     0.50, <-1,0,0>
>     0.75, <0,0,-1>
>     1.00, <1,0,0>
>     1.25, <0,0,1>
>   }
>
> And implement it using MySpline(val)
>
> Does val not indicate the position along the spline, i.e, 0.1 would be 10%
> along the length of the spline etc.?
>

No. MySpline(0.1) calculates the value of the spline where the spline
parameter=0.1
In your example the distances between each 'control point' is the same, but
consider the following

#declare MySpline=
 spline {
  cubic_spline
  -0.25, <0,0,0>
   0.00,<1,0,0>
   0.25,<2,0,0>
   0.50,<4,0,0>
   0.75,<8,0,0>
   1.00,<16,0,0>
   1.25,<32,0,0>
  }

In the above case MySpline(0.1) will give me a value of <1.249,0.000,0.000>
which
is definatly not 10% of the way along the spline

Gail
--
*************************************************************************
* gsh### [at] monotixcoza                *   Step into the abyss,           *
* http://www.rucus.ru.ac.za/~gail/   *   and let go.          Babylon 5 *
*************************************************************************
* Just think of me as the storm before the calm     Magic: The Gathering*
*************************************************************************


Post a reply to this message

From: Gail Shaw
Subject: Re: Length along a spline
Date: 18 Oct 2001 04:26:17
Message: <3bce9229@news.povray.org>
"Warp" <war### [at] tagpovrayorg> wrote in message
news:3bcdc908@news.povray.org...
>   I would use Colefax's spline macros. It does that and a lot more.
>
> http://www.geocities.com/ccolefax/spline/index.html
>


I'll have a look at those. Thanks Warp

Gail
--
*************************************************************************
* gsh### [at] monotixcoza                *   Step into the abyss,           *
* http://www.rucus.ru.ac.za/~gail/   *   and let go.          Babylon 5 *
*************************************************************************
* Just think of me as the storm before the calm     Magic: The Gathering*
*************************************************************************


Post a reply to this message

From: Mike Williams
Subject: Re: Length along a spline
Date: 18 Oct 2001 13:00:50
Message: <1JvWPCA35rz7EwbU@econym.demon.co.uk>
Wasn't it Gail Shaw who wrote:
>I'm trying to write a macro to create a chain that follows a spline and I've
>run
>into a problem. As far as I can tell there is no way to get the value of a
>spline
>at equal distances along it.
>
>Does anyone know of a way to place objects at equal distances along
>a spline, short of trial and error?

Well, trial and error isn't too bad for this sort of task. Make two
passes down the spline in tiny steps, accumulating the vlength() between
each pair of points. On the first pass simply collect the grand total.
On the second pass, place an object whenever the length since the last
object reaches 1/N of that total length.

My making the steps sufficiently small you should be able to get pretty
good accuracy in reasonable time. I'd guess that a positioning accuracy
of half a pixel would be sufficient for most purposes.

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

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