distance from given point to given ellipse

后端 未结 7 1942
抹茶落季
抹茶落季 2021-02-05 08:07

I have an ellipse, defined by Center Point, radiusX and radiusY, and I have a Point. I want to find the point on the ellipse that is closest to the given point. In the illustrat

7条回答
  •  生来不讨喜
    2021-02-05 08:30

    I've solved the distance issue via focal points.

    For every point on the ellipse

    r1 + r2 = 2*a0

    where

    r1 - Euclidean distance from the given point to focal point 1

    r2 - Euclidean distance from the given point to focal point 2

    a0 - semimajor axis length

    I can also calculate the r1 and r2 for any given point which gives me another ellipse that this point lies on that is concentric to the given ellipse. So the distance is

    d = Abs((r1 + r2) / 2 - a0)

提交回复
热议问题