java 已经圆心坐标(x0,y0)及圆上一点坐标(x1,y1),及圆半径(r),求圆上任意一点的坐标,求高手解答急
java已经圆心坐标(x0,y0)及圆上一点坐标(x1,y1),及圆半径(r),求圆上任意一点的坐标,高分求高手解答,急急急!要给出详细的java算法,谢谢啦...
java 已经圆心坐标(x0,y0)及圆上一点坐标(x1,y1),及圆半径(r),求圆上任意一点的坐标,高分求高手解答,急急急! 要给出详细的java算法,谢谢啦
展开
2个回答
展开全部
Bresenham算法画圆,可以参考下
public void drawCircle(int x, int y, int d, Color frameColor){
int xc = x + d / 2;
int yc = y + d / 2;
int r = d / 2;
int dx = r;
int dy = 0;
int xChange = 1 - 2 * r;
int yChange = 1;
int radiusError = 0;
while( dx >= dy){
plot8CirclePoints(xc, yc, dx, dy, frameColor);
dy++;
radiusError += yChange;
yChange += 2;
if(2 * radiusError + xChange > 0){
dx--;
radiusError += xChange;
xChange += 2;
}
}
}
private void plot8CirclePoints(int x, int y, int dx, int dy, Color color){
graph.setArrayData(x + dx, y + dy, color);
graph.setArrayData(x - dx, y + dy, color);
graph.setArrayData(x - dx, y - dy, color);
graph.setArrayData(x + dx, y - dy, color);
graph.setArrayData(x + dy, y + dx, color);
graph.setArrayData(x - dy, y + dx, color);
graph.setArrayData(x - dy, y - dx, color);
graph.setArrayData(x + dy, y - dx, color);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询