Jump to content

Ellipse from 5 Points


Recommended Posts

Hi All!

Little background: I was searching for an implementation (or at least a full explanation) of constructing an ellipse from 5 points. 5 points exactly define an ellipse, so it's not a data fitting problem. To my surprise, I couldn't find any solutions that can be used as it is or any full explanations. All I could find was pointers into the proper direction (matrix math) but my math is so rusty that I could not implement anything from those information ("just calculate the determinant with some symbolic math library or do it on paper haha and goodness comes"). I was a bit upset because I wasn't doing homework, I actually needed that function.

 

Anyhow, after finding a small hint in one of the threads, I could go through the thing and implementet the algorithm. Maybe it will be useful for anyone who is looking for exactly that thing.

It's not that nice, not optimised, I guess many of the math could be optimized/simplified, but it's working at least.

Precision: I'm not sure. For my needs, it's precise enough, I'm not an expert in condition of the matrix or other calculations.

I think the names are self explaining, but If you have questions, don't hesitate to ask. The formulas and the thread I found most usable are included on the block diagram.
Input: array of coordinates (x,y in a cluster).
Output:

  • ellipse parameters: center, two radii and angle of the first axis
  • the coordinates of the axis endpoints
  • the five t parameter values of the input points (t parameter for the parametric equation of the ellipse), so for example you can draw ellipse arc between two of the points
  • If the ellipse cannot be constructed, it results in some NaNs here and there... No extra checks added

2 subvis are also implemented, but maybe they are already in the LV base package and just missed them:

  • parametric equation for arbitrary ellipses (or polar equation, my math is that rusty I can't even express properly what I mean)
  • CCW angle between two vectors (result in 0....2 PI range), it's used to calculate the t parameters for the points. This is where I feel there's some redundancy or redundant trigonometric calculations.

 

Thank's for any feedback!

EDIT: I added a small demo program. You can move the 5 points on a graph.

2D_ellipse_parametric_equation.vi 2D_ellipse_from_5pts.vi 2D_ccw_angle.vi

Ellipse_Demo.vi

Edited by Lipko
  • Thanks 1
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.