This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center。
7年前关闭。
问题是,我没有找到合适的圈子。例如,如果我输入坐标:9,8和半径:8 ...我只会得到很少的点。.有人可以指导我如何获取完整的圆吗,此代码有什么问题?我们不能使用任何内置函数。
7年前关闭。
问题是,我没有找到合适的圈子。例如,如果我输入坐标:9,8和半径:8 ...我只会得到很少的点。.有人可以指导我如何获取完整的圆吗,此代码有什么问题?我们不能使用任何内置函数。
最佳答案
这是不对的if(sqrt(pow(i,2)+ pow(j,2))== radius)
这两个值完全相等是非常罕见的。相反,您应该进行测试以查看两个数字是否大致相等。像这样if (fabs(sqrt(pow(i,2)+ pow(j,2)) - radius) <= 0.001)
这测试sqrt(pow(i,2)+ pow(j,2))
和radius
是否在0.001之内。您可能需要将0.001的值更改为其他值。这取决于您的坐标系。