POV-Ray : Newsgroups : povray.newusers : Bezier Curves. : Re: Bezier Curves. Server Time
26 Jun 2024 01:29:21 EDT (-0400)
  Re: Bezier Curves.  
From: Warp
Date: 26 Nov 2012 10:26:33
Message: <50b38a28@news.povray.org>
Le_Forgeron <lef### [at] freefr> wrote:
> The bezier_spline is an alternate kind of cubic spline. Points 1 and 4
> specify the end points of a segment and points 2 and 3 are control
> points which specify the slope at the endpoints. Points 2 and 3 do not
> actually lie on the spline. They adjust the slope of the spline. If you
> draw an imaginary line between point 1 and 2, it represents the slope at
> point 1. It is a line tangent to the curve at point 1. The greater the
> distance between 1 and 2, the flatter the curve. With a short tangent
> the spline can bend more. The same holds true for control point 3 and
> endpoint 4. If you want the spline to be smooth between segments, points
> 3 and 4 on one segment and points 1 and 2 on the next segment must form
> a straight line and point 4 of one segment must be the same as point 1
> on the next segment.

There's actually an easy trick if you want to construct a smooth spline
that goes through a set of points, using bezier curves:

Create a bezier curve between each pair of points (so that the endpoints
of the bezier are those two points, obviously), and take the direction and
length of the middle bezier control points from the previous and next points.

Ok, that was confusing. Let me explain it with a more concrete example:

Let's say that you want a smooth spline that goes through the points A, B,
C, D, and so on. To do that, create a bezier between each of those points,
so the endpoints of the first bezier are A and B, the second one are B and C,
and so on.

Now, there are two secondary bezier control points attached to B (one for
the first spline and another for the second). Make them tangential to the
A-C line (ie. have the same direction.) Their length should be the distance
between A and C multiplied by a factor (eg. something like 0.2 or such.)

Likewise the two secondary control points attached to C should be tangential
to the B-D line (and their length a fraction of the distance between B and D)
and so on.

The only remaining question is what should be the direction and length of
the secondary control point at A, and the one at the last point. One
possibility for this is to not create a bezier between A and B at all
(nor between the two last points.)

If you choose the length factor properly, I believe that what you get will
be extremely close to a cubic spline.

-- 
                                                          - Warp


Post a reply to this message

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