# Tracing an ellipse from major axis and given points

Hello,

I have a serie of given points but i dont know the minor axis length, could someone know how to trace an ellipse passing through those points?

Ellipse problem.gh (10.0 KB)

Hi -

Thatās not a trivial task to solve.

The following thread has 2 Grasshopper graphs that might get you further:

Also, we have the āFit ellipse through points functionā feature request on the list as RH-62823.
-wim

I canāt help wondering how you know the major axis points but donāt know the ellipse?

Hereās a Galapagos solution:

Ellipse problem_2021Oct29bb.gh (14.1 KB)

P.S. Responded to the wrong personā¦

If you already have the major axis you could also get the ellipse by intersecting lines with the circle and scale1D:

Ellipse problem.gh (16.1 KB)

For more general ellipse/conic problems I see thereās this recent plugin

3 Likes

This solution with Python 3.9 and Hops

Ellipse problem.gh (10.2 KB)

``````from flask import Flask
import ghhops_server as hs
import numpy as np
from skimage.measure import EllipseModel

hops = hs.Hops(app)

@hops.component(
"/ellipse",
name="Ellipse",
description="Ellipse from points",
#icon="",
inputs=[
hs.HopsPoint("Points", "P", "List of points",hs.HopsParamAccess.LIST),
],
outputs=[
hs.HopsString("Result", "R", "Result output"),
]
)

def ellipse(points):
pts = []
for p in points:
x = p.X
y = p.Y
pt = (x, -y)
pts.append(pt)

a_points = np.array(pts)

ell = EllipseModel()
ell.estimate(a_points)

xc, yc, a, b, theta = ell.params

return [xc,-yc,-theta,a,b]

if __name__ == "__main__":
app.run()
``````

There are other codes:

1 Like

Is anyone able to install this?

I installed it from PackageManager and it worked

This is one of the cases where OP provided just a single case and then left the thread (iām joking)
Iād like to try some algorythms but i fear other cases would have a different general situation.

Thank Daniel. Package Manager seemed to work, but then nothing shows up when I restart Rhino. Anyway, itās not your problem.

I think @daniel.christev is the developer of that one

Compare results between Python/Hops and Regular components:

Ellipse problem.gh (17.5 KB)

Thank you very much for your solution!

I had the same problem, you should try with a previous version of hops, it works well with the 0.4.1