js 畫曲線和圓 並限制圓的渲染範圍

2022-02-27 01:30:14 字數 1876 閱讀 1870

通過三個點的座標可確定一條雙曲線。

公式:1)y=ax^2+bx+c;

2) y=a(x-k)+h;

通過已知三點可確定a,b,c,h,k

2.通過圓心座標(a,b)和半徑r可確定乙個圓,和已知的x座標:

公式:1)r^2=(x-a)^2+(y-b)^2

3.圓是否相交,可通過求得圓心距g確定,圓心(x1,y1)和(x2,y2):

1) g^2=(x1-x2)^2+(y1-y2)^2

4.確定圓上的點的x座標是否在曲線內點(x,y),1中求得的a,h,k;算出當前y值時的所在的曲線x值得範圍:

1)  x1 =math.sqrt((y -h) / a) + k, x2 =k - math.sqrt((y - h) / a);

以下為原始碼:

1

<

html

>

2<

head

>34

head

>

5<

body

>69

<

script

>

10var

maindoc

=document.getelementbyid(

"main");

11function

_drawpoint(x, y)

22var

circle

=function

(options)

27circle.prototype =36

},37

_pointcoordinate:

function

(x) , ];42}

43};

4445

varhyperbola

=function

(options)

56hyperbola.prototype =65

},66

_init:

function

() ,

75_pointcoordinate:

function

(x) , ];

80},

81_randomcircle:

function

() );

92c.draw();

93this

.circlelist.push(c);

94count--;

95}96}

97}98,

99move:

function

() 115

}116

},117

checktheboundary:

function

(x, y)

128return

true

;129

},130

checkthecircle:

function

(x, y, r)

137return

true

;138

}139

};140

varh

=new

hyperbola();

141h.draw();

142h._randomcircle();

143//

setinterval(function () , 1000);

146script

>

147body

>

148html

>

view code

效果:

利用Python畫ROC曲線和AUC值計算

前言 roc receiver operating characteristic 曲線和auc常被用來評價乙個二值分類器 binary classifier 的優劣。這篇文章將先簡單的介紹roc和auc,而後用例項演示如何python作出roc曲線圖以及計算auc。auc介紹 auc area un...

多邊形和圓的面積並

include include include include include const long double eps 1e 10 const long double pi acos 1.0 using namespace std struct point void operator point...

Canvas 畫貝塞爾曲線(二階曲線和三階曲線)

效果圖為動態圖,乙個小圓點沿著曲線運動,並顯示實時點座標。二階 三階 一 實現思路 1.用兩個canvas實現,乙個繪製曲線,乙個繪製運動圓點。2.繪製曲線 可以通過canvas提供的api方法繪製。二階 quadraticcurveto controlx,controly,endingpointx...