Re: [問題] 請益如何記錄不規則的座標值呢
不知道五月都快過了才回應算不算挖考古文
請問你有試過轉極座標嗎?
(theta,r) to (x,y)
x=r cos(theta)
y=r sin(theta)
(x,y) to (theta,r)
r=sqrt(x*x+y*y)
theta=arctan(y/x)
然後定義
(theta1,r1) > (theta2,r2)
if
(theta2 > theta1) or (theta2 == theta1 and r1>r2)
然後隨便一個排序法就可以排出順時針的排序了
-----
Sent from JPTT on my HTC One dual 802d.
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 222.251.34.243
※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1432165617.A.3EA.html
推
05/21 10:24, , 1F
05/21 10:24, 1F
討論串 (同標題文章)
完整討論串 (本文為第 2 之 2 篇):