0

This is an effort to detect and fit a set of points to an ellipse. I have a method to take x,y data and generate a conic formula, but due to the nature of the polynomial there are 2 solutions for Y

Example: 1x² +-0.008xy +0.976y² + -316.916x +-151.345y + 27708.8 = 0

I have a Method to get the Y value for both solutions, but the primary issue is with the nature of a conic. Near the edges, small changes in X result in large changes in Y. This creates an issue when fitting the original x,y coordinates to the conic. Most point data will result in whole integers and now in order to best fit to the conic, the x values need to be transformed in some way that escapes me.

I found a rough solution, but it just throws a huge amount of x,y data at the polynomial to see what has a solution. I could do this and then just find the closest point to my original data to fit to the conic, but this just seems stupid. Has to be a better way.

At a minimum If I can find the max an min of a conic then I can minimize the number of possible data points but even that seems dumb.

Any help on how to fit existing data to a conic polynomial would be awesome and greatly appreciated.

Rick De
  • 1
  • 2
  • 3
    I have a feeling that you may be better at [Mathematics.SE](https://math.stackexchange.com/) since you are looking for a process of solving not necessarily the code to do it. – Ron Beyer Apr 06 '18 at 15:05
  • Well you aren't wrong, but i'm really looking for a code solution to my problem as i'm a programmer not a mathematician. I know someone has had to deal with more robust math problems and finding max and min of a polynomial in code seems like it should be trivial but I haven't been able to find a solution. I'm about to dive into R.Net since there is a whole lot more Maths in there. – Rick De Apr 06 '18 at 15:13
  • I doubt there would be many C# examples of this, if there are any. Most operations like this are done in MATLAB or C++. Your best best might be to use a third-party math library in C++. – Dan Wilson Apr 06 '18 at 15:17
  • This model looks like it is linear in six coefficients (there are no unknown exponents or anything like that), and one of them can be locked to `1`. Solving such a problem is straightforward computation of a matrix pseudoinverse. Any linear algebra library should be capable of doing this -- C# may not have as many options as Fortran or C++, but it has multiple that will get this particular job done. – Ben Voigt Apr 06 '18 at 15:41

0 Answers0