POV-Ray : Newsgroups : povray.general : converting Bezier splines to B-splines Server Time
26 Dec 2024 13:52:11 EST (-0500)
  converting Bezier splines to B-splines (Message 1 to 1 of 1)  
From: Lloyd Lee-Lim
Subject: converting Bezier splines to B-splines
Date: 27 Feb 2006 01:25:00
Message: <web.44029afc5b6c2495d652bc250@news.povray.org>
I wanted to sweep a sphere along a path defined as a Bezier spline.  The
sphere_sweep object doesn't support Bezier splines, so I figured out how to
convert the path to B-splines.  It works, but I have a question.

The formulas turned out to be fairly simple.  If you have a Bezier segment
with control points b1, b2, b3, b4, then the corresponding B-spline has the
following control points s1, s2, s3, s4:

s1 = 6 * b1 - 7 * b2 + 2 * b3
s2 = 2 * b2 - b3
s3 = -b2 + 2 * b3
s4 = 2 * b2 - 7 * b3 + 6 * b4

So if my Bezier path is:

<0, 0>,
<0, 1>,
<1, 1>,
<1, 0>,
<1, 0>,
<1, -1>,
<2, 1>,
<2, 0>,
<2, 0>,
<2, -1>,
<4, 0>,
<3, 0>

The corresponding sphere sweep would be:

sphere_sweep {
    b_spline
    4,
    <2, -5, 0>, 0.1,
    <-1, 1, 0>, 0.1,
    <2, 1, 0>, 0.1,
    <-1, -5, 0>, 0.1
}
sphere_sweep {
    b_spline
    4,
    <3, 9, 0>, 0.1,
    <0, -3, 0>, 0.1,
    <3, 3, 0>, 0.1,
    <0, -9, 0>, 0.1
}
sphere_sweep {
    b_spline
    4,
    <6, 7, 0>, 0.1,
    <0, -2, 0>, 0.1,
    <6, 1, 0>, 0.1,
    <-6, -2, 0>, 0.1
}

The conversion works, but each Bezier segment is converted to a separate
B-spline.  The Bezier path is smooth and continuous, so it should be
possible to obtain one B-spline instead of three.  It's not obvious to me
how to do this.

Can someone explain how to get one B-spline instead of separate B-splines
for each Bezier segment?

Thanks,
Lloyd Lee-Lim


Post a reply to this message

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