通过给定的点集识别图形的类型

发布于 2024-08-29 10:36:52 字数 83 浏览 8 评论 0原文

我正在尝试设计一个程序,在给定一组点(x,y)的情况下绘制图形,并且它还应该仅借助点的帮助来识别曲线(直线、双曲线、抛物线)。 有算法可以做到这一点吗?

I'm trying to design a program that draws graphs given a set of points (x, y), and it also should recognize the curve (straight line, hyperbole, parabola), with only the help of the points.
Is there an algorithm to do that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

笑红尘 2024-09-05 10:36:52

如果曲线可以是直线或二次曲线(双曲线、抛物线、椭圆、圆),则需要五个点。

如果这五个点共线,则得到一条直线。 (或者退化二次曲线?但是如果您期望直线,这应该表示一条直线。)

如果四个点共线,则有一个退化二次曲线,由通过四个共线点的线和通过第五个点的任何线给出与第一条线不平行。

如果三个共线,则有一个退化二次曲线,由通过三个共线点的线和通过其他两个点的线给出。 (除非这两条线平行,在这种情况下,这不是二次曲线。)

如果没有三个点共线,则您将拥有唯一的非退化二次曲线。

要找到该二次曲线的方程 (Ax^2 + Bxy + Cy^2 + Dx + Ey + F = 0),请查看 此页面,特别是DETAILS部分中的公式。输入五个 x 和 y 值,根据 x 和 y 计算矩阵的行列式,这将为您提供二次曲线的公式。然后请参阅此处,根据 A 的值找出您拥有哪种圆锥曲线, B 和 C。

如果有超过 5 个点,请选择五个点(最好没有三个点共线),找到圆锥曲线,然后检查其余点是否位于圆锥曲线上。

You'll need five points if the curve could be a straight line or a conic (hyperbola, parabola, ellipse, circle).

If the five points are collinear, you have a straight line. (Or a degenerate conic? But if you're expecting straight lines, this should indicate a straight line.)

If four are collinear, you have a degenerate conic, given by the line through the four collinear points and any line through the fifth point that is not parallel to the first line.

If three are collinear, you have a degenerate conic, given by the line through the three collinear points and the line through the two other points. (Unless these two lines are parallel, in which case this isn't a conic.)

If no three points are collinear, you have a unique, non-degenerate conic.

To find the equation for this conic (Ax^2 + Bxy + Cy^2 + Dx + Ey + F = 0), take a look at this page, specifically the formula in the DETAILS section. Put in your five x and y values, calculate the determinant of the matrix in terms of x and y, and this will give you the formula of your conic. Then see here to figure out what kind of conic you have based on the values of A, B and C.

If you have more than 5 points, pick five points (preferably so no three are collinear), find the conic, and then check that the remaining points lie on the conic.

菊凝晚露 2024-09-05 10:36:52

您可以通过观察函数极限来做到这一点,但这可能不是这个问题的最佳解决方案(我的意思是像 y = sqrt(x*x-1) 这样的抛物线函数中的问题)。
对于直线,您可以通过 2 个随机点计算 y = ax + b,并检查其他点是否符合此条件(如果是)。这是一条直线,如果没有,您可以检查其他 2 个异常,或者什么也不检查。也许其他人可以解决接下来的两个案例?

You can do it by watching the function extreme but is maybe not optimal solution for this problem (i mean a problem in parabola function like that y = sqrt(x*x-1)).
For straight line you can calc y = ax + b by the 2 random point's and check what other points equal this condition, if yes. This is straight line if no you may check a 2 other exceptions or nothing from it. Maybe somone else get solution for next 2 cases?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文