Ellipse5Pts01 is a script which forms an ellipse from 5 point picked by the user.
The standard MoI ellipse factory is used, but the center and axes points must first be calculated.
See EllipseThru5Pts.pdf for some background.
It is anticipated that the user could set up a cPlane, to assure that the picked points are planar.
The picked points can be any 5 distinct planar points on the ellipse to be. (z = 0)
The chosen points must be consistent with an "oval" elliptical shape,
for example, not a rectangle with one point chosen inside.
There can be no 3 points that are colinear.
Note that (B*B - 4*A*C) must be < 0 for the conic to be an ellipse.
Please consider it an alpha version. There is no error checking or warning messages.
There may be some more advanced ways of guiding point selection?
Or maybe even a C++ factory?
The Verbose version has many Alert messages, used in debugging. (commented out.)
Initially there were a lot of problems picking points on a test ellipse, especially points with x=0 or y = 0.
Some selections seemed to be degenerate numbers. Lots of NAN's were generated, and +/- infinity.
And the NAN selections seemed to occur for the "same" picked points which at other times worked OK.
This problem seems to be gone(?).
Creating an ellipse by 5 points is available in Blender, Autocad, FoodForRhino, and Matlab.
All of the information used to create this script is available on the web, over 100 sites were studied.
StackExchange has helpful forums.
The pieces of code are relatively simple, but every little piece needed a lot of study and understanding.
Is was very challenging to get the script written and debugged. Lots of matrix math is involved.
Using Eigenvalues and Eigenvectors was a bust in getting the angles. Probably needed a few tweeks.
So other equations were used.
CodeProject has alternative es6 javascript for the Doolittle LUP decomposition,
which was translated to es5 online with
https://babeljs.io/, (Try It Out tab), but was not used,
due to limited javascript skills.
This script was written in order to fit an ellipse to one of the symmetry planes of an online pseudo-G*mb*c stl,
in order to make a NURBS model. There is a standing challenge from them.
After much debugging, suddenly the code worked.
- Brian