Recognition of a graph type by a given set of points

I am trying to create a program that draws graphs given a set of points (x, y), and also needs to recognize a curve (line, hyperbola, parabola) using points only. Is there an algorithm for this?

+2


a source to share


2 answers


You will need five points if the curve can be straight or conical (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, that should indicate a straight line.)

If four are collinear, you have a degenerate conic, defined by a line through 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, defined by a line through three collinear points and a line through two other points. (If the two lines are not parallel, then it is not a conic.)



If the three points are not 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 section DETAILS

. Put in five x and y values, calculate the determinant of the matrix in terms of x and y, and that will give you your conic formula. Then take a look here to figure out which conic you have based on the A, B, and C values.

If you have more than 5 points, choose five points (preferably none of them collinear), find the conic, and then check that the rest of the points lie on the conic.

+1


a source


You can do this by observing an extreme function, but it may not be the optimal solution for this problem (I mean a problem in a parabola function such as y = sqrt (x * x-1) ). For a straight line, you can output y = ax + b to 2 random points and check what other points are equal to this condition if yes. This is a straight line, if not you can check for 2 other exceptions or none of these. Maybe someone else will get a solution for the next 2 cases?



+1


a source







All Articles