Help regarding the "spline_math_curve.html" page
Translated by Google Traduction,
from the french version : Help - Info, in french.
A few decades ago I learned about degree 3 spline functions and wrote programs that use them to pass a curve through given points in a plane.
I've been waiting for such curves to be implemented in software like Inkscape
and FreeCAD for a long time.
I saw at the end of december 2022 on Youtube the excellent video of Freya Holmér
called: "The continuity of Splines"
Unfortunately, the curve that I would call "Math-spline",
based on spline functions and that I implemented in the web page:
is not described by Freya Homér nor used in the software that I know of.
Here are some characteristics of this "Math-spline" curve:
° of tangents varying continuously along the curve
° of radii of curvature varying continuously along the curve, it is G2
° pass through all given points
° does not require any additional points to define the curve
° can easily be closed
° can have break points, so where the tangent varies discontinuously
° the influence of the points is done practically on the 8 neighboring segments of the point
° is invariant under rotation, symmetry and homothety.
° is easy to calculate, quickly
Explanations of some features of the implementation page
This page is not used for anything other than to make tests on the generation
of curves passing through given points and using the spline functions.
I would love that such curves could be generated in software like Inkscape
The illustration of generation of a curve passing through given points is done in 2 dimensions, in an 800x800 canvas.
Obviously, we can generalize the way to curves passing through points defined in a 3-dimensional space and even in a space of any dimensions.
Various points can be placed by clicking in the canvas, with the "Shift" key pressed.
By clicking on a point, the point and the corresponding curve are selected.
The selected point can be deleted with the "Delete point" button.
You can add a point before the selected point by clicking and pressing "Ctrl+Shift".
G0 gives a continuous curve, but with non-continuous tangents.
Each segment is a line segment.
Each point only influences the previous and next segment.
G1 gives a curve whose tangent varies continuously.
The tangents at the points are calculated in naive and non-optimal ways.
Each point only influences the previous two segments and the next two.
G1 other (best) is like the previous case, except that
the tangents at the points are calculated in more optimal ways.
This way is preferable to the previous one.
G2 (best) gives a curve whose tangent not only varies continuously, but also the curvature varies continuously.
This is clearly the preferable way among the 4 proposed.
Each point practically only influences the previous four segments and the next four.
Mathematically, each point influences the whole curve, but this influence decreases rapidly with the distance between the point and the segment concerned.
uniform dT = 1 uses a parametrization of the curve giving the same time to go from one point to the next.
distance dependent (better) uses a parametrization of the curve giving a time to pass from one point to the next which is equal to the distance in pixels between the two end points of the segment.
Is only used in the previous choice "G2".
This is the recommended choice.
dT = length of the segment (useless) uses a parametrization of the curve giving a time to go from one point to the next which is equal to the length of the segment.
It requires more calculations and almost does not change from the previous method.
Is only used in the previous choice "G2".
Practically, the calculation of the length of the segment drawn is done each time the curve is drawn. It is this length that is used. This is the reason why starting from the "uniform dT = 1" case and passing to this case, the curve may vary slightly during the 3 or 4 updates of the drawing of the curve.
Press the "Rotate" button to refresh the curve drawing.
The question arose as to whether the choice of axes to represent the points as a couple of numbers influenced the generated curve.
The answer is no.
This shows up mathematically. It is also tested by accepting to subject a linear transformation to the points or to the curve.
T11 to T22 gives the coefficients of the linear transformation matrix.
The "Rotate" button generates a rotation matrix.
The following checkboxes allow to display curves having undergone the linear transformation.
Clone points, generates a copy of the points of the first curve, which undergo the linear transformation, then the "Math-spline" curve corresponding to these points is generated.
Clone curve, generates a copy of the first curve, then it undergoes the linear transformation.
If the linear transformation is a rotation, a symmetry or a dilation, the two cases of cloning give exactly the same curve, which shows the independence of the choice of axes.
For a more general linear transformation,
if the case where dT = 1 is chosen, the two curves remain the same.
if another case is chosen, the two curves can be different. This is because the distance between points is no longer preserved.
Closed curve, allows you to close the currently selected curve.
Broken point, generates a broken point at the selected point.
In this case, the tangent around this point no longer varies continuously.
These points are, like the first and the last point, characterized by the fact that the second derivative of the components X(t) and Y(t) of the curve have zero second derivative.
Sound on, allows you to activate or deactivate a sound when you click on a point.
Click to add a spline with .... Points.
This button is used to generate a "Math-spline" curve with the number of points requested.
To test that the generation of "Math-spline" curves works quickly, you can generate a curve containing thousands of points, to see that the calculation and display is done in a fraction of a second.
From about 10,000 points, the calculation is slower and is clearly felt.
You can also use this button to generate curves with only a few points, to compare various curves.
Only the first curve can be cloned.
For more information, in particular on mathematics and algorithms, see
French version .pdf and .odt
Version automatically translated into English
.pdf and .docx
with Google Translate.
In this Web page, Youtube videos in french on this subject.
Plan du Site :
Page mise à jour le 20 janvier 2023 par Bernard Gisin
( Envoyer un e-mail )
Hébergement par : www.infomaniak.ch