In the same thread as this question, I am giving this another shot and ask SO to help address how I should take care of this problem. I'm writing a bash script which needs to perform the following:
- I have a circle in
x
andy
with radiusr
. - I specify
resolution
which is the distance between points I'm checking. - I need to loop over x and y (from -r to r) and check if the current (x,y) is in the circle, but I loop over discrete
i
andj
instead. - Then
i
andj
need to go from-r/resolution
to+r/resolution
. - In the loop, what will need to happen is
echo "some_text i*resolution j*resolution 15.95 cm"
(note lack of$
's because I'm clueless). This output is what I'm really looking for.
My best shot so far:
r=40.5
resolution=2.5
end=$(echo "scale=0;$r/$resolution") | bc
for (( i=-end; i<=end; i++ ));do
for (( j=-end; j<=end; j++ ));do
x=$(echo "scale=5;$i*$resolution") | bc
y=$(echo "scale=5;$j*$resolution") | bc
if (( x*x + y*y <= r*r ));then <-- No, r*r will not work
echo "some_text i*resolution j*resolution 15.95 cm"
fi
done
done
I've had just about enough with bash and may look into ksh like was suggested by someone in my last question, but if anyone knows a proper way to execute this, please let me know! What ever the solution to this, it will set my future temperament towards bash scripting for sure.