[算法学习] 计算几何

给定两个点\(N_1, N_2\),求出绕他们的\(n\)边形的中心。

我们可以通过相似算出中心坐标。

mid = make_pair((p[x].first + p[y].first) / 2, (p[x].second + p[y].second) / 2);      //N1,N2的中心点
o.first = mid.first + (p[y].second - p[x].second) / tan(PI * (y - x) / n) / 2;
o.second = mid.second - (p[y].first - p[x].first) / tan(PI * (y - x) / n) / 2;

将一个点按照原点逆时针旋转一个角度。

\[x = x\cos \theta + y\sin \theta \]

\[y = y\cos\theta - x\sin\theta \]

讲一个点绕某个中心点\((x_1,y_1)\)旋转一个角度

\[x = x\cos \theta + y\sin \theta + x_1 \]

\[y = y\cos\theta - x\sin\theta+y_1 \]

posted @ 2020-09-01 15:35  Hock  阅读(190)  评论(0编辑  收藏  举报