473,803 Members | 4,400 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Ellipse fitting in python?

Is there a python package out there that supports fitting a set of 2D
points to an ellipse? I haven't been able to find one.

Thanks!

Ron
Jul 18 '05 #1
6 6634
on********@hotm ail.com (Ron Kneusel) writes:
Is there a python package out there that supports fitting a set of 2D
points to an ellipse? I haven't been able to find one.


This is a set of points with some noise (scatter), right?

A not-very-thoughtful answer: a sledgehammer method is to throw an
implementation of a standard nonlinear least-squares algorithm at the
problem. For example, SciPy contains a wrapper of MINPACK's nonlinear
LS solver . There are several implementations of the same
(Levenburg-Marquardt) algorithm in pure Python floating around, too.

If there's no scatter, it's time to dig out your old algebra textbooks
:-)
John
Jul 18 '05 #2
John J. Lee wrote:
on********@obvi ous.com (Ron Kneusel) writes:
Is there a python package out there that supports fitting a set of 2D
points to an ellipse? I haven't been able to find one.


This is a set of points with some noise (scatter), right?

A not-very-thoughtful answer: a sledgehammer method is to throw an
implementation of a standard nonlinear least-squares algorithm at the
problem. For example, SciPy contains a wrapper of MINPACK's nonlinear
LS solver . There are several implementations of the same
(Levenburg-Marquardt) algorithm in pure Python floating around, too.


A quick comment in case it's not obvious: an ellipse is not a function in
Cartesian coordinates, and most standard LS solvers expect a function. So
it's probably best to convert things over to polar before feeding the data to
the LS solver.

f
Jul 18 '05 #3
Ron Kneusel wrote:
Is there a python package out there that supports fitting a set of 2D
points to an ellipse? I haven't been able to find one.


It's not so easy; it's a nonlinear orthogonal distance regression problem.
I know of a FORTRAN package and I myself have a (more general) package written
in Scilab ( a Matlab "clone" )

If you have just a few datasets, I'll compute a fit for you.
But implementing it in Python would be much work.
--
Helmut Jarausch

Lehrstuhl fuer Numerische Mathematik
RWTH - Aachen University
D 52056 Aachen, Germany
Jul 18 '05 #4
Aloha,

Ron Kneusel wrote:
Is there a python package out there that supports fitting a set of 2D
points to an ellipse? I haven't been able to find one.


See http://www.magic-software.com/Approximation.html
Here are C++ Sources, you will need a interface like SWIG for using this
in python.

Wishing a happy day
LOBI
Jul 18 '05 #5
On Wed, 14 Jul 2004, Fernando Perez wrote:
A quick comment in case it's not obvious: an ellipse is not a function in
Cartesian coordinates, and most standard LS solvers expect a function. So
it's probably best to convert things over to polar before feeding the data to
the LS solver.


You could break both the ellipse and the data into two pieces (say, y>=K
and y<K). Polar coordinates might get you more uniform results, though.

Jul 18 '05 #6
Helmut Jarausch wrote:
Ron Kneusel wrote:
Is there a python package out there that supports fitting a set of 2D
points to an ellipse? I haven't been able to find one.

It's not so easy; it's a nonlinear orthogonal distance regression problem.
I know of a FORTRAN package and I myself have a (more general) package
written
in Scilab ( a Matlab "clone" )


I wrote a wrapper to the FORTRAN ODRPACK.

http://starship.python.net/crew/kern...odr-0.6.tar.gz
If you have just a few datasets, I'll compute a fit for you.
But implementing it in Python would be much work.

Jul 18 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1407
by: Grant Edwards | last post by:
I'm looking for a surface fitting library for Python. Something like the least-squares module in scientific python, except I want to fit a surface (z = f(x,y)) instead of a curve (y = f(x)). I found a couple other curve fitting libraries (some are wrappers to C/Fortran libs I don't have), and I found a curve and surface-fitting web page (www.zuzun.com) that's written in Python -- I found a couple postings by James R.
5
9244
by: lgeastwood | last post by:
I have tweaked the PictureBox97.mdb (Stephen Lebans <www.lebans.com>) code to nicely draw lines, rectangles and circles to the specs that I input. I'm at a loss though with trying to setup an Ellipse Drawing Function. The following code I found on Google works in VB5 and draws an ellipse shape no problem using the Circle Method. Private Sub cmdDrawEllipse_Click() Dim X As Long, Y As Long Dim ElipseWidth As Integer, ElipseHeight As...
11
8742
by: Christopher Ireland | last post by:
Hello! Using the definition for en ellipse (http://en.wikipedia.org/wiki/Ellipse) I can draw an arc of points. However, the end points of this arc do not coincide with the end points of an arc drawn with the DrawArc method, e.g. public partial class Form2 : Form { public Form2() {
2
12671
by: weird0 | last post by:
I wanted to draw an ellipse using c# with System.Drawing.Graphics. I tried out several tutorials and none of them worked and there seems to be something missing. One did execute without any errors but it did not render an ellipse on the form. I want to create an ellipse with just a new project with one form default, that is Form1. I want the draw ellipse function to be in some other class,say Shapes( user-defined) and then call it in the...
3
9820
by: illusion.admins | last post by:
I am trying to code something to tell me if a selected point is in a particular ellipse. For the ellipse I know how it was constructed (know the x,y, and width, height). But if I just check to see if the point is in the rectangle making up the ellipse wouldn't that possibly give me a false answer? Eg if the point is the upper left coordinate of the rectangle...this point is in the rectangle making up ellipse but NOT the ellipse itself. ...
1
3573
by: PankajGaur | last post by:
Hi, I need to create a Ellipse shaped user control which have folloiwng attributes: 1) The edges are smooth 2) The control shuld only be selected when click on the ellipse shape & not when click on the empty area of Client Rectangle What I have done so far: I override the OnPaintMethod as below:
8
6745
by: =?Utf-8?B?RGFu?= | last post by:
I would like to draw an ellipse on a windows form and through mouse drags stretch, rotate and relocate the ellipse. Thanks in advance - Dan
0
1377
by: =?Utf-8?B?UGFua2FqR2F1cg==?= | last post by:
Hi, I need to create a Ellipse shaped user control which have folloiwng attributes: 1) The edges are smooth 2) The control shuld only be selected when click on the ellipse shape & not when click on the empty area of Client Rectangle What I have done so far: I override the OnPaintMethod as below:
4
5233
by: Evelien | last post by:
Dear python-users, I am trying to do a non-linear least squares fitting. Maybe trying is not the best word, as I already succeeded in that. At the moment I am using leastSquaresFit from Scientific Python. I know of other least squares routines, such as the one in scipy.optimize and I believe there is also one in numpy. Now here is my question: in my search for a good algorithm, I was not able to find any non-linear least squares fitting...
0
9703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9564
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10316
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10295
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10069
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9125
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7604
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4275
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2970
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.