java拓扑圆形布局算法

int centerX = 400;//圆心坐标
int centerY = 300;
int radius = 200;//半径
//count: 节点数目            
for (int i= 0; i<count; i++)
{
    int x = centerX+ (int)(radius * Math.cos(Math.PI * 2 / count * i));
    int y = centerY+ (int)(radius * Math.sin(Math.PI * 2 / count * i));
    node[i].setX(x);
    node[i].setY(y);
}

 

你可能感兴趣的:(java,算法)