Assume we have the following coordinates:
coord = Table[{i, j}, {j, 1.0, -1.0, -0.1}, {i, -1.0, 1.0, 0.1}]
What is the most efficient way to calculate the radius r
. i.e. r = sqrt(i^2+j^2)
and set r
to 0
for all r
whose value is greater than 1.
So basically it will get a list like {0,0,0,0,0.989,0.979...0,0,0}
.
I already have my own solution, which is not elegant I think. And I hope the algorithm could be as fast as possible. So I would like to hear more sophisticated ideas.
Thanks!