File Exchange

image thumbnail

Sphere Fit (least squared)

version 1.1 (30.7 KB) by

Fits a sphere to a set of noisy data. Does not require a wide arc or many points.

52 Downloads

Updated

View License

Editor's Note: This file was selected as MATLAB Central Pick of the Week

Given a set of data points, this function calculates the center and radius of the data in a least squared sense. The least squared equations are used to reduce the matrix that is inverted to a 3x3, opposed to doing it directly on the data set. Does not require a large arc or many data points. Assumes points are not singular (co-planar) and real...
Created on R2010b, but should work on all versions.

Comments and Ratings (42)

chu guo

Dear Alan,
Great work. May I have your related paper? I am also interested in this algorithm. my email: 790775266@qq.com
thank you!

Hi Alan,

Could you please let me know how we would cite your work?

Thanks,
Bugra

Mayank Murthy

Omid Heidari

Dear Alan, Great work...May I have your relate paper?
my email: karollkv@hotmail.es

nay zhao

Ximena Ayala

Dear Alan,
Great work. May I have your relate paper? I am interested in this algorithm. my email: ximenag89@gmail.com

Many thanks

XIANGHUA LIU

Hi Alan,

Great work! Thanks for this great function! Is there any chance for me to get the related papers explaining this method?

Thanks a lot!

andyxhliu@gmail.com

Hi Alan,
Great work I would be happy if you could send me the related paper describing the method.
mariogarmu86@gmail.com

Dear Alan,

Thanks for the function. I would be interested in the related papers. May I ask you to send it to me? Thanks in advance.

Best regards,

Roderik

E-mail: roderik.berthelin@outlook.com

Jan Mervart

Dear Alan,
I also thank you for your function and I am interested in the related papers, too.

Best regards,
E-mail: gertbra@gmail.com

Ed

Ed (view profile)

Hi Alan,
this sphereFit algorithm gives me nightmares, I'm looking to understand it since days. Please send me the related papers, too! :/
Email: jizaz84@googlemail.com

Do you think it will be possible to reduce the DOF within the sphereFit? I need to pin the XY position to a line.

Best regards,
Ed

Ed

Ed (view profile)

joe W

joe W (view profile)

Dear Alan,
Firstly, thank you for your function.I hope you can send me the related papers.Thanks again.

Best regards
E-mail: wqh806393670@163.com

niels st

Dear Alan,
Your function works great! I'm interested in the algorithm behind your code. Would it be possible to get the related papers?

Best regards
niels.steffen@tu-harburg.de

Alan Jennings

Alan Jennings (view profile)

Hi Jack,
I'm glad this is useful for you. If you notice, there's a symmetry that you can extend to N dimensions. If you're very savy, you can do it progamatically without a for loop; but I thought that would make the code harder to understand. The derivation also extends to N dimensions, so the answer will still be the least square error (of the squared distance).
HTH, Alan

jack

jack (view profile)

Hello Alan,
Does your code works in n dimension where n>=3 ?
If not can you help me in making it work?

please advise.

Thanks in advance.

jack

jack (view profile)

Hello Alan,
Does your code works in n dimension where n>=3 ?
If not can you help me in making it work?

please advise.

Thanks in advance.

Lutas

Lutas (view profile)

Andrei

Andrei (view profile)

Alan,

I agree with the other comments. Very nice function. Could you also send me the mentioned reference papers.

Regards

Tom

tmhedges@gmail.com

Dear Alan,
thanks for this great function! Is there a possibility for me to get the related papers explaining this method ?
Thanks a lot in advanced.
Regards

Navy

Navy (view profile)

Navy

Navy (view profile)

That's just what I need.

Kao

Kao (view profile)

Dear Alan,
Great work. May I have your relate paper? I am interested in this algorithm. my email: fox19851120@gmail.com

Many thanks

Kao

Kao (view profile)

Casey

Casey (view profile)

li

li (view profile)

good work!

Patrick

Dear Alan,
thanks for this great function! Is there any chance for me to get the related papers explaining this method, as well? Tried to research it the whole day - without succes...
Thanks a lot!
patrick-fink@gmx.net

Sa

Sa (view profile)

Dear Alan,
Outstanding work! Could you send me the related paper explaining this method?
samuel.reimer@tum.de

Farsat Balata

Dear Alan, could you please, explain more about the two vectors A and B. I don't understand the rationality of Error function you defined as sum((x-xc)^2+(y-yc)^2+(z-zc)^2-r^2)^2,. Is the initial sphere center is taken for partial of the error of each parameter for example xc= mean(x), yc=mean (y) and zc= mean (z) and the function E = sum((xi-mean(x))^2+(y-mean(y))^2+(z-mean(z))^2-r^2)^2 and then, minimze the function E. many thanks

Farsat Balata

Dear Alan, pointing to my previous comment, I have just want to correct the equation
E = sum((xi-mean(x))^2+(yi-mean (y))^2+(zi-mean(z))^2-r^2)^2
Regards

Hi Alan,
Great work I would be happy if you could send me the related paper describing the method.
isxfha@nottingham.ac.uk

JamesAb

Hi Alan. Great code! I really appreciate if you could send me the related paper describing the method:

jamesabott@yahoo.com

Many thanks!

Simao

Simao (view profile)

Hi Alan. Great work! can you please send me the relating papers?

simao.britodaluz@griffithuni.edu.au

much appreciated

Chloe

Chloe (view profile)

Hi Alan, any chance you could please send me the relating papers to c.carson@ncl.ac.uk?

Thanks for the code. Works perfect!

Laurens

Works great!

I was wondering if you could send me the paper as well (email: laurens.slot@gmail.com).

Also, how would this look if the radius was known?

luo

luo (view profile)

Dear Alan, can you send me the related papers? You know, I don't understand the rationality of Error function you defined as sum((x-xc)^2+(y-yc)^2+(z-zc)^2-r^2)^2, since I thought it was supposed to be sum(sqrt((x-xc)^2+(y-yc)^2+(z-zc)^2)-r)^2. My email: lhwsky@mail.ustc.edu.cn. many thanks

Daniel Lopes

Daniel Lopes (view profile)

Great piece of code!

Tim

Tim (view profile)

works great for my task, and thank you for sending me the related papers! :-)

Updates

1.1

Since the matrix A is symmetric, I changed the calculation to avoid superfluous calculations. Runs about 25% faster, and even better for large data sets.

MATLAB Release
MATLAB 7.11 (R2010b)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

sphereFit/

sphereFit/html/