Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pts = {{-0.2, -0.2}, {0.2, 0.2}};
- NIntegrate[Nearest[pts-> "Distance", {x, y}] , {x, y} [Element] Disk[]]
- (*Nearest: The default distance does not give a real numeric distance when
- applied to the point pair {x,y} and {-0.2,-0.2}.*)
- pts = {{-0.2, -0.2}, {0.2, 0.2}};
- Block[{f, nf},
- nf = Nearest[pts -> "Distance"]; (* precompute NearestFunction *)
- f[x_?NumericQ, y_?NumericQ] := (* NumericQ prevents evaluation on symbolic x, y *)
- First@nf[{x, y}]; (* Nearest returns a list; extract distance with First *)
- NIntegrate[f[x, y], {x, y} ∈ Disk[]]
- ]
- (* 1.69082 *)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement