POV-Ray : Newsgroups : povray.pov4.discussion.general : Spline improvements : Spline improvements Server Time
3 Mar 2024 09:30:12 EST (-0500)
  Spline improvements  
From: Allen
Date: 14 Jan 2009 19:00:00
Message: <web.496e7b5d8d57a39c8f162dfb0@news.povray.org>
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;
        #local cur = 0;
        #local accum = 0.0;
        #while(cur < _count - 1)
            accum, _points[cur],
            #local accum = accum + vlength(_points[cur + 1] - _points[cur]) /
            #local cur = cur + 1;
        1.0, _points[cur]

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:


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.

Post a reply to this message

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