[學習筆記]計算幾何基礎

來源:互聯網
上載者:User

標籤:線段   dsa   記憶   res   dao   size   blog   add   err   

三角函數

向量

線性空間中有大小和方向的量.

座標表示:$P(x_1,y_1),Q(x_2,y_2)$.

$\overrightarrow{PQ}=(x_2-x_1,y_2-y_1)$.

$|PQ|=\sqrt{(x_2-x_1)^2+(y_2-y_1)^2}$.

向量運算

$a=(x_1,y_1),b=(x_2,y_2)$.

  • 加法

$a+b=(x_1+x_2,y_1+y_2)$.

  • 減法

$a-b=(x_1-x_2,y_1-y_2)$.

  • 點乘

$a\;\cdot\;b=x_1x_2+y_1y_2$.

$a\;\cdot\;b=|a||b|cos<a,b>$

應用:求兩向量夾角,判斷是否垂直($cos90$°$=0$).

  • 叉乘

$a\;\times\;b=x_1y_2-x_2y_1$.

$|a\;\times\;b|=|a||b|sin<a,b>$.

$a\;\times\;b=0$,共線.

判斷線段交

$(AC\;\times\;AD)(BC\;\times\;BD)\;\leq\;0$且$(CA\;\times\;CB)(DA\;\times\;DB)\;\leq\;0$.

向量旋轉

將$a(x_1,y_1)$逆時針旋轉$\theta$(弧度)得到$b(x_1cos\theta-y_1sin\theta,x_1sin\theta+y_1cos\theta)$.

$P.S.$只改變方向(長度不變).記憶方法:旋轉$\pi/2$得到的結果$(-y_1,x_1)$.

三點共線

夾角為$0$且$a\;\times\;b=0$.

點是否在射線上

夾角為$0$且點乘$\geq\;0$.

$<0$?反向!

多邊形面積

設多邊形頂點依次為$P_1,P_2,...,P_n$.

$\large{S=|\frac{\sum_{i=1}^{n-1}\overrightarrow{OP_i}\times\overrightarrow{OP_{i+1}}+\overrightarrow{OP_n}\times\overrightarrow{OP_{1}}}{2}}|$.

點到直線垂足

點到直線垂足$D,ED\;\perp\;AB$.

旋轉$\overrightarrow{AB}\pi/2$.

直線求交.

圓的位置關係

$d$為兩圓圓心距,$R,r$分別為兩圓半徑.

$d>R+r$ 外離;

$d=R+r$ 外切;

$|R – r|<d<R+r$ 相交;

$d=|R–r|$ 內切;

$d<|R–r|$內含.

點是否在凸多邊形內

隨機射線

推薦

http://dev.gameres.com/Program/Abstract/Geometry.htm#判斷點是否在多邊形中

[學習筆記]計算幾何基礎

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.