File:Regression cercle gruntz anim.gif
From Wikimedia Commons, the free media repository
Jump to navigation
Jump to search
Size of this preview: 349 × 600 pixels. Other resolutions: 139 × 240 pixels | 390 × 670 pixels.
Original file (390 × 670 pixels, file size: 14 KB, MIME type: image/gif, looped, 8 frames, 4.0 s)
File information
Structured data
Captions
Summary[edit]
DescriptionRegression cercle gruntz anim.gif |
English: Circle fitting using the Gruntz algorithm.
Français : Régression circulaire avec l'algorithme de Gruntz. |
Date | |
Source |
Own work Gruntz, D., Finding the Best Fit Circle, in "The MathWorks Newsletter", Vol. 1, p. 5, 1990 http://groups.google.com/group/sci.math.num-analysis/msg/f936dad6ff285069 |
Author | Cdang (Christophe Dang Ngoc Chan) |
Parameters of the circle:
- xc = 3.04;
- yc = 0.746;
- r = 4.11.
Scilab source
This media was created with Scilab, a free open-source software. Here is a listing of the Scilab source used to create this file. |
// **********
// Initialisation
// **********
clear;
chdir('monchenim/')
// données (D. Gruntz)
X0 = [0.7, 3.3, 5.6, 7.5, 6.4, 4.4, 0.3, -1.1];
Y0 = [4.0, 4.7, 4.0, 1.3, -1.1, -3.0, -2.5, 1.3];
// Paramètres de Newton-Raphson
precision = 1e-7; // condition d'arrêt
itermax = 60; // idem
Ainit = [0,0, 1] // cercle initial
// **********
// fonctions
// **********
function [ACx, ACy, AC] = caracteristiques(Xexp, Yexp, A)
// calcule les caractéristiques du modèle
// par rapport aux points expérimentaux
// C(1) : xcentre (scalaire)
// C(2) : ycentre (scalaire)
// Xexp, Yexp : points mesurés (vecteur de nombres)
// ACx : vecteur de composante x des vecteurs AC>
// " y "
// AC : longueurs des vecteurs AC>
ACx = (A(1) - Xexp)';
ACy = (A(2) - Yexp)';
AC = ((ACx.^2 + ACy.^2).^(0.5));
endfunction
function [S] = residus(Xexp, Yexp, C)
// Xexp, Yexp : coordonnées des points expérimentaux (vecteurs)
// C : coordonnées du centre (vecteur)
[ACx, ACy, AC] = caracteristiques(Xexp, Yexp, C);
res = abs(C(3) - AC);
S = sum(res);
endfunction
function []=affichage(X, Y, A, R, k)
clf;
subplot(2,1,1)
plot2d(X, Y, style = -1) //, frameflag=4)
isoview(-1.5, 7.5, -3.5, 5.5);
xstring(-1.8, 5.3, 'C('+string(A(1))+' ; '+string(A(2))+') ; r = '+string(A(3)))
// modèle
plot(A(1), A(2), 'r+')
diametre = 2*A(3);
xarc(A(1) - A(3), A(2) + A(3),...
diametre, diametre,...
0, 360*64)
a = get('hdl'); // ellipse
a.foreground = 5; // couleur
subplot(2,1,2)
plot2d(R, rect=[1, 0, 8, 33])
xstring(0.5, 0.1, 'α = '+string(k)+' ; R = '+string(R($)))
// halt
endfunction
function [A, R]=regression_circulaire(Xexp, Yexp, Ainit, imax, epsilon)
// Xexp, Yexp : points expérimentaux
// A(1) : xcentre
// A(2) : ycentre
// A(3) : rayon
// Ainit : valeur initiale de A
// imax, epsilon : condition d'arrêt
i = 1;
k = 1;
A = Ainit';
dA = [1 1 1]';
drapeau = %t; // pour la 1re itération
R(1) = residus(Xexp, Yexp, A')
affichage(Xexp, Yexp, Ainit, R, 1)
nom = 'cercle_gruntz'+string(i)+'.png';
xs2png(0,nom)
while drapeau & (i <= imax)
i = i+1;
[ACx, ACy, AC] = caracteristiques(Xexp, Yexp, A);
J = [ACx./AC, ACy./AC, -ones(ACx)]; // matrice des vecteurs unité
f = -(AC - A(3)*(ones(Xexp))');
dA = J\f;
drapeau2 = %t // pour une 1re exécution
while drapeau2 & (k>=0.1) // teste la divergence sur 1 étape
A = A + k*dA;
R(i) = residus(Xexp, Yexp, A')
drapeau2 = (R(i) >= R(i-1)) // vrai si diverge
if drapeau2 then k = k*0.75; // atténue si diverge
else k0 = k; // pour affichage de la valeur
k = (1 + k)/2; // réduit l'atténuation si converge
end
end
drapeau = (abs(R(i) - R(i-1)) > epsilon)
disp('i = '+string(i)+' ; k = '+string(k0)+' ; R = '+string(R(i)))
affichage(Xexp, Yexp, A', R, k0)
nom = 'cercle_gruntz'+string(i)+'.png';
xs2png(0,nom)
end
endfunction
// **********
// programme principal
// **********
// lecture des données
// Xdef, Ydef : vecteurs ligne
Xdef = X0;
Ydef = Y0;
fenetre = scf(0); // création de la fenêtre graphique
fenetre.figure_size = [400,800];
// regression
[Aopt, res] = regression_circulaire(Xdef, Ydef, Ainit, itermax, precision)
centre = Aopt(1:2);
rayon = Aopt(3);
R = res($);
print(%io(2), centre)
print(%io(2), rayon)
print(%io(2), R)
Licensing[edit]
I, the copyright holder of this work, hereby publish it under the following licenses:
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled GNU Free Documentation License.http://www.gnu.org/copyleft/fdl.htmlGFDLGNU Free Documentation Licensetruetrue |
This file is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported, 2.5 Generic, 2.0 Generic and 1.0 Generic license.
- You are free:
- to share – to copy, distribute and transmit the work
- to remix – to adapt the work
- Under the following conditions:
- attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
- share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.
You may select the license of your choice.
File history
Click on a date/time to view the file as it appeared at that time.
Date/Time | Thumbnail | Dimensions | User | Comment | |
---|---|---|---|---|---|
current | 13:18, 12 December 2012 | 390 × 670 (14 KB) | Cdang (talk | contribs) | {{Information |Description ={{en|1=Circle fitting using the Gruntz algorithm.}} {{fr|1=Régression circulaire avec l'algorithme de Gruntz.}} |Source ={{own}}, from http://groups.google.com/group/sci.math.num-analysis/msg/f936dad6ff285069 |Au... |
You cannot overwrite this file.
File usage on Commons
There are no pages that use this file.
Metadata
This file contains additional information such as Exif metadata which may have been added by the digital camera, scanner, or software program used to create or digitize it. If the file has been modified from its original state, some details such as the timestamp may not fully reflect those of the original file. The timestamp is only as accurate as the clock in the camera, and it may be completely wrong.
GIF file comment | Created with Scilab and GIMP |
---|