Re: Smooth Curves

Hello,

if one uses a first order approximation (Catmull-Rom) or
a second order approximation depends on the task.
Obviously if one really wants to approximate a curve,
the given points are taken from, locality is not very 
important and if available, one will calculate the
derivatives independently and use cubic Beziers
with calculated control points.
If the intended curve is not known and the derivatives
not known as well, one has to guess the derivatives.
If one takes only the neighbour points, this is obviously
only a very rough guess, but changes or uncertainties
far away do not result in a change of the local path
segment. But to get some good quality for visual 
presentation, one needs a lot of points in the path.
If all points are taken for the guess, the
opposite takes place, this results in a pretty good
approximation, but small changes far outside have
influence on the local shape a little bit.
Additionally there is some more number crunching
to derive the local shape from all points.

With a second order approximation still the calculations
are simple, but the approximation even with only a few
points is significantly better than for a first order 
approximation. For visual presentation a second order
approximation is a good compromise. And taking into
account five points instead of only three is not such
a big difference for local behaviour.

However, if one wants only to connect the points somehow
smoothly, obviously the first order approximation does
the job - therefore it is ok, if you only have this in mind
and not necessary to get something, that looks like
or is a good approximation of a curve the points are
taken from.

For the discussion of a new command to close paths
smoothly, I provided already a comparison:
http://hoffmann.bplaced.net/svgueb/interpol1en.php
(The paths and shapes have title attributes to indicate the
meaning or used approximation methods).
One can see, that the blue curve with a first order
approximation does not really look like the circle to
be approximated, already the second order approximation
does a much better job. However, if one increases the
number of path points by a factor of two or three, the
visual result for the first order approximation is typically
ok as well. 
This means, if you like small file sizes or the number of
available points are fixed and you are not forced to have 
only a strong local dependency of the curve, the second 
order approximation will be the better choice.
You can have already some fun with the first order 
approximation as well - the calculated curve
will depend significantly on both - the points and
the first order interpolation method.

Both methods are mathematically simple (and presumable
known for hundreds of years).  Different representation
can be transformed into each other.
For SVG it is more relevant in both cases to be careful
with the boundary conditions. 
For closed curves this is simple as well, one just has
to repeat the points of the path to get the missing
points to get something meaningful.
For open paths this is more tricky. 
Best choice without additional information are some 
asymmetrical formulas - but one cannot completely 
avoid, that the quality of the appearance at the ends 
is lower.
If one wants to provide additional information at the ends - 
how to add this additional information to path data in
a way that fits to the current end point notation?
Or do we need only a new element independently
from general path data? I think, to be able to combine
would be more interesting for authors.


Olaf

Received on Tuesday, 14 May 2013 09:57:53 UTC