圆锥分类【难度:2级】:

可以在锥体的不同部分获得圆锥曲线,并且我们可以获得三个主要组:椭圆,双曲线和抛物线。

<img src =“http://i.imgur.com/4NdOkgf.png?2”title =“source:imgur.com”/> </一>

圆是椭圆的特例。

在数学中,所有圆锥曲线可以用以下等式表示:

<img src =“http://i.imgur.com/SVTomxD.jpg?1”title =“source:imgur.com”/> </一>

``A,B,C,D,E和F```是在实数数字字段中可能具有不同值的系数。

黑塞在十九世纪,介绍了使用不变量,有用的工具,以便对不同的圆锥曲线进行分类。

不变量M,N和S是:

<img src =“http://i.imgur.com/v7xVjyX.png?1”title =“source:imgur.com”/> </一>

可以证明,如果坐标系变化,例如移动坐标系的中心或旋转坐标轴,或者做两件事,不变量将具有相同的值,即使系数为“A”, B,C,D,E和F```改变。

下图显示了M,N和S的值如何对圆锥曲线的性别和圆锥曲线退化时的特殊情况(点或线)进行分类,或者它们是虚构的:

<img src =“https://i.imgur.com/2hUJNeN.jpg?1”title =“source:imgur.com”/> </一>

函数classify_conic()将完成这项工作。 该函数将接收圆锥方程的不同系数,并将分类结果作为字符串输出

classify_conic(A,B,C,D,E,F)==结果
classifyConic(A,B,C,D,E,F)==结果
classify_conic(a,b,c,d,e,f)==结果

我们来看一些案例:

情况1
A = 1,B = 1,C = 1,D = 2,E = 2,F = -4
classify_conic(A,B,C,D,E,F)==“一个真正的椭圆”

案例2
A = 1,B = 1,C = -1,D = 2,E = 2,F = 4
classify_conic(A,B,C,D,E,F)==“真正的双曲线”

情形3
A = 1,B = 0,C = 0,D = 4; E = 4,F = 4
classify_conic(A,B,C,D,E,F)==“真正的抛物线”
情况1
A = 1,B = 1,C = 1,D = 2,E = 2,F = -4
classifyConic(A,B,C,D,E,F)==“真正的椭圆”

案例2
A = 1,B = 1,C = -1,D = 2,E = 2,F = 4
classifyConic(A,B,C,D,E,F)==“真正的双曲线”

情形3
A = 1,B = 0,C = 0,D = 4; E = 4,F = 4
classifyConic(A,B,C,D,E,F)==“真正的抛物线”

显示以上三种情况的图表如下:

<img src =“http://i.imgur.com/nUE4mcM.png?1”title =“source:imgur.com”/> </一>

具有退化或想象的圆锥曲线的特殊情况的消息将是:

#对于椭圆性别:
“一个假想的椭圆”
“一个退化的椭圆:一点”

#对于双曲线性别:
“退化的双曲线:两条相交的线”

#对于抛物线性别:
“退化的抛物线:两条平行线”
“退化的抛物线:两条重合线”
“退化的抛物线:两条想象的线条”

好好享受!!
#注意:

  • 给定系数ABCDE和F,(abcdef `在Ruby中)将始终是整数。
  • 为了避免精度问题,应该通过Sarrus规则获得“M”和“N”的行列式值。 (参见:https://en.wikipedia.org/wiki/Rule_of_Sarrus)

英文原题:

The conic curves may be obtained doing different sections of a cone and we may obtain the three principal groups: ellipse, hyperbola and parabola.

The circle is a special case of ellipses.

In mathematics all the conics may be represented by the following equation:

A, B, C, D, E and Fare coefficients that may have different values in the real numeric field.

Hesse in the nineteenth century, introduced the use of the invariants, useful tool in order to classify the different conic curves.

The invariants M, N, and Sare:

It may be proved that if the system of coordinates changes, for example moving the center of the system of coordinates or rotating the coordinates axes, or doing both things, the invariants will have the same value, even though the coefficients A, B, C, D, E, and Fchange.

The following chart shows how the values of M, N and Sclassify the gender of the conics and the special cases when the conics are degenerated (points or lines) or they are imaginary:

The function classify_conic()will do this work.
This function will receive the different coefficients of the conic equation and will output the result of the classification as a string

classify_conic(A, B, C, D, E, F) == result
classifyConic(A, B, C, D, E, F) == result
classify_conic(a, b, c, d, e, f) == result

Let’s see some cases:

Case1
A = 1 , B = 1, C = 1, D = 2, E = 2, F = -4
classify_conic(A, B, C, D, E, F) == "A real ellipse"

Case2
A = 1 , B = 1, C = -1, D = 2, E = 2, F = 4
classify_conic(A, B, C, D, E, F) == "A real hyperbola"

Case3
A =1, B = 0, C = 0, D = 4; E = 4, F = 4
classify_conic(A, B, C, D, E, F) == "A real parabola"
Case1
A = 1 , B = 1, C = 1, D = 2, E = 2, F = -4
classifyConic(A, B, C, D, E, F) == "A real ellipse"

Case2
A = 1 , B = 1, C = -1, D = 2, E = 2, F = 4
classifyConic(A, B, C, D, E, F) == "A real hyperbola"

Case3
A =1, B = 0, C = 0, D = 4; E = 4, F = 4
classifyConic(A, B, C, D, E, F) == "A real parabola"

The graph showing the above three cases is the following:

The messages for the special cases, having degenerated or imaginary conics will be:

# For elliptic gender:
"An imaginary ellipse"
"A degenerated ellipse: One point"

# For hyperbolic gender:
"A degenerated hyperbola: two intersecting lines"

# For parabolic gender:
"A degenerated parabola: two parallel lines"
"A degenerated parabola: two coinciding lines"
"A degenerated parabola: two imaginary lines"

Enjoy it!!
#Note:

  • The given coefficients A, B, C, D, E andF, (a,b,c,d,eandf` in Ruby) will be always integers.
  • In order to avoid precision problems, the determinant values of M and N should be obtained by the rule of Sarrus.

最佳答案合集(多种解法)