【发布时间】:2021-06-29 08:48:21
【问题描述】:
我想计算圆圈内散落的红点。
我的代码是:
using PyPlot # Here I define the circle
k = 100
ϕ = range(0,stop=2*π,length=k)
c = cos.(ϕ)
d = sin.(ϕ)
# Here I defined the scattered points with the circle
function scatterpoints(x,y)
n = 1000
x = -n:n
x = x / n
y = rand(2*n+1)
scatter(-x, -y;c="red",s=1)
scatter(x, y;c="red", s=1)
plot(c,d)
end
scatterpoints(x,y)
我的方法(伪代码)是这样的:
using LinearAlgebra
if norm < radius of circle then
amount of points in circle = amount of points in circle + 1
end
很遗憾,我不确定如何在 Julia 中实现这一点。
【问题讨论】:
标签: geometry julia linear-algebra scatter-plot