Ellipse through five picked points

Next
 From:  bemfarmer
9971.1 
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

EDITED: 6 Oct 2020 by BEMFARMER


  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
9971.2 In reply to 9971.1 
It might be beneficial to add an input for a constant z_plane value.
- B
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
9971.3 In reply to 9971.2 
After using the script in a 3D situation, and having trouble establishing a z_plane view of the desired location for the ellipse,
a slight modification was made to the script. Did a rotation to the stl model to get a z_plane view, cPlane did not do the job.
In alpha version 02, the zPt1 coordinate of the first point picked, was used for the z value of the center point and major and minor axes points.
The z values of the other picked points should be the same, but are still ignored by the script.

- Brian
Attachments:

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
9971.4 
Sphere through 4 points looks even easier to do.
There are some non-planar and non-colinear constraints.
May give it a try...
- B

http://paulbourke.net/geometry/circlesphere/

EDITED: 5 Oct 2020 by BEMFARMER

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
 From:  bemfarmer
9971.5 In reply to 9971.4 
Got the Sphere4Pts02 alpha script to work.
- Brian
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged
 

Reply to All Reply to All