n点的圆上近似位置

时间:2015-05-02 08:19:44

标签: geometry computational-geometry approximation

我正在努力解决以下问题: 我得到n点和半径,我必须将它们放在尽可能对称的圆上。

目前,我使用过这样的东西:

float theta = 360.0f / n;
int i = 0;
for (Word w : e.getValue()) {
    double newX = Math.sin(theta * i) * RADIUS + I_OFFSET_X;
    double newY = Math.cos(theta * i) * RADIUS + I_OFFSET_Y;
    mxCell v2 = (mxCell) graph.insertVertex(parent, null, w.getValue(), newX, newY, OW_WIDTH, OW_HEIGHT,"shape=ellipse");
    graph.insertEdge(parent, null, "", v1, v2);
    i++;
}

其中n是我的分数。

这适用于足够大的n,但对于n=3例如,我得到类似的内容:

n=3

我真的希望有类似的东西:

enter image description here

(绘图技巧不好......)

所以基本上,尽可能对称的东西会很棒。

有关如何解决此问题的任何提示?

谢谢< 3

1 个答案:

答案 0 :(得分:1)

感谢Jongware,答案非常明显。因为我正在处理Java,所有#include <algorithm> #include <iostream> #include <map> int main() { std::map<int, std::string> a,b; a[0] = "0"; a[1] = "1"; b[0] = "0"; std::cout << "b ⊆ a? " << std::includes(a.begin(), a.end(), b.begin(), b.end()) << " (will be 1)\n"; b[1] = "1"; std::cout << "b ⊆ a? " << std::includes(a.begin(), a.end(), b.begin(), b.end()) << " (will be 1)\n"; b[2] = "2"; std::cout << "b ⊆ a? " << std::includes(a.begin(), a.end(), b.begin(), b.end()) << " (will be 0)\n"; } 参数都应该是弧度。 修正:

sin/cos

像魅力一样工作

相关问题