POV-Ray : Newsgroups : povray.general : Length along a spline : Re: Length along a spline Server Time
7 Aug 2024 15:12:58 EDT (-0400)
  Re: Length along a spline  
From: Mike Williams
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.