POV-Ray : Newsgroups : povray.pov4.discussion.general : Spline improvements : Re: Spline improvements Server Time 3 Mar 2024 11:16:38 EST (-0500)
 Re: Spline improvements
 From: Woody Date: 19 Feb 2009 20:05:00 Message:
```
{
"@context": "https://schema.org",
"@type": "DiscussionForumPosting",
"@id": "#web.499e01aac26f2bd249b4acd50%40news.povray.org",
"dateCreated": "2009-02-20T01:05:00+00:00",
"datePublished": "2009-02-20T01:05:00+00:00",
"author": {
"@type": "Person",
"name": "Woody"
}
}
"Allen" <bri### [at] yahoocom> wrote:
> I would like to see the following addition to splines in POV4, support for
> automatic values to create evenly spaced items.  If there exists a spline S
> that is an auto-spline, then the distance between any two points on the spline
> S(N*M) and S(N*(M+1)) would be equal. ( S(0.2) - S(0.0) == S(0.4) - S(0.2), and
> so on)
>
> I have currently created a macro that automatically creates a spline from an
> array.  It first determines the total distance of points and then creates a
> spline  with values ranging from 0.0 to 1.0 based on the distance of any item
> from its start:
>
> #macro auto_spline(_points, _count)
>     // First, determine total length of points
>     #local cur = 0;
>     #local total = 0.0;
>     #while(cur < _count - 1)
>         #local total = total + vlength(_points[cur + 1] - _points[cur]);
>         #local cur = cur + 1;
>     #end
>     spline
>     {
>         linear_spline
>         #local cur = 0;
>         #local accum = 0.0;
>         #while(cur < _count - 1)
>             accum, _points[cur],
>             #local accum = accum + vlength(_points[cur + 1] - _points[cur]) /
> total;
>             #local cur = cur + 1;
>         #end
>         1.0, _points[cur]
>     }
> #end
>
> One idea would to introduce a new keyword 'auto_spline' that behaves much like a
> regular spline, except it is not given values, but only points:
>
> auto_spline
> {
>     linear_spline
>     <point1>,
>     <point2>,
>     ...
>     <pointN>
> }
>
> That after reading spline elements it would auto-generate the values such that
> the value for any given element is equal to the total distance from that point
> to the first point through all intermediate points, divided by the total spline
> distance.  Such a spline would take into consideration that different spline
> types would cause the segments to have different lengths.

Is this related to the thread at