Given 5 distinct points on a two-dimensional plane, determine the type of conic section formed by the points. The output shall be one of
- The points will be in general linear position, meaning that no three points are collinear, and thus the conic passing through them will be unique.
- The coordinates of the 5 points will be decimal numbers between -10 and 10, inclusive.
- The precision for the decimal/float values should be the precision of your language's native float/decimal type. If your language/data type is arbitrary-precision, you may use 12 digits after the decimal point as the maximum required precision, rounding toward zero (e.g.
1.0000000000005 == 1.000000000000).
- Capitalization of the output does not matter.
ellipsewhen the conic section is actually a circle is not allowed. All circles are ellipses, but you must output the most specific one.
On floating point inaccuracies and precision:
I'm trying to make this as simple as possible, so that issues with floating point inaccuracies don't get in the way. The goal is, if the data type was "magical infinite precision value" instead of float/double, then everything would work perfectly. But, since "magical infinite precision value" doesn't exist, you write code that assumes that your values are infinite precision, and any issues that crop up as a result of floating point inaccuracies are features, not bugs.
(0, 0), (1, 5), (2, 3), (4, 8), (9, 2) => hyperbola (1.2, 5.3), (4.1, 5.6), (9.1, 2.5), (0, 1), (4.2, 0) => ellipse (5, 0), (4, 3), (3, 4), (0, 5), (0, -5) => circle (1, 0), (0, 1), (2, 1), (3, 4), (4, 9) => parabola