POV-Ray : Newsgroups : povray.binaries.scene-files : Making functions for natural cubic splines : Re: Making functions for natural cubic splines Server Time
24 Apr 2024 21:18:06 EDT (-0400)
  Re: Making functions for natural cubic splines  
From: Nevado
Date: 12 Oct 2014 23:30:00
Message: <web.543b44d05b2bbe7b6dce1a360@news.povray.org>
"Tor Olav Kristensen" <tor### [at] TOBEREMOVEDgmailcom> wrote:

> After looking at the JustBasic language, it seems to be a very "poor" language,
> with regards arrays, functions, parameter passing, documentation etc. (But it
> seems to work with Wine in Linux =)

Hi Tor
Thanks for your contribution :-)
I agree about the language, and I first believed this was an impossible task,
but I did find a way to draw PointWriter shapes with cubic splines in JustBasic.
(Luckily, two dimensions are enough for my purposes.) My method takes four user
points A, B, C and D, solves the cubic curve that connects them, draws the
middle segment from point B to C, then moves on to solve B, C, D and E, draws
the segment from C to D and so on. This produces nicely flowing curves. But I
keep running into problems when the curve doubles back on itself, needing two
y-values for the same x-value. The problem arises because the points are
connected in order of increasing x, not in the order the points are clicked.
So when I want this:

       D
         *
          *
           C
         *
       *
     B
   *
A

I get this:


       D
      *  *
      *   *
     *     C
     *
     *
     B
   *
A


My present workaround is to pre-test x for this doubling back situation, then
simply swap x/y values for the input coordinates before solving the polynomial,
effectively mirroring the curve, and then mirror it back when drawing it by
swapping output coordinates. This takes care of some problem situations.
But there will still be cases where both the x- and the y-value double back on
themselves, so the problem remains after mirroring the curve. For example, if
you try to draw a simple cube by clicking four points at right angles to each
other, it won't work, unless I come up with a new idea.


Post a reply to this message

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