syntax - More simple math help in bash! -


In the same thread, I'm giving this one more shot and to know how to take care of this problem SO Ask. I am writing a Bash script, which needs to do the following:

  1. I have x and y radius r .
  2. I specify resolution , which is the distance between points I see.
  3. I need a loop on X and Y (R-R to R) and check whether the current (X, Y) is in the circle or not, but I instead discrete i and j
  4. then i and j to -r / resolution to + r / resolution Need to go
  5. In the loop, what would be required to do echo "some_text i * resolution j * resolution 15.95 cm" ( $ due to lack of reason because me I do not know). This is the output that I actually see.

My best shot is by now:

  r = 40.5 resolution = 2.5 end = $ (echo "scale = 0; $ r / $ resolution "). (= (- (= () = (; (j = -end; j & lt; = end; j ++)); x = $ (echo "scale = 5; $ i * (i = -end ; I & lt; = end; i ++)); $ resolution ") | BC y = $ (echo" scale = 5; $ h * $ resolution ") | BC if ((x * x + y * y & Lt; = r * r)) ;; & lt; - no, r * r will not work "some_text i * resolution j * resolution 15.95 cm" before done  

Just about me There was a lot and I was suggested by someone in my last question, but as if hairstyle is examined, but if anyone knows the right way to execute it, Please tell me! What will be the solution to it, it will definitely set its future nature to bass scripting.

You want to add pipes to $ () in BC instead of.

  end = $ (echo" scale = 0; $ r / $ resolution ") | BC  

Usage

  end = $ (echo "scale = 0; $ r / $ resolution" | BC)  

should help a little

edit and here Solution. Scale for i for

  r = 40.5 resolution = 2.5 and = $ (echo "$ (Seq - $ {end} $ {end}) = $; $ r / $" | BC); For J for $ (Seq - $ {end} $ {end}); What x = $ (echo "scale = 5; $ i * $ resolution" | bc) y = $ (echo "scale = 5; $ h * $ resolution" | BC) check = $ (echo "($ x ^ 2 + $ Y ^ 2) & lt; = $ r ^ 2 "| BC) if [$ {check} -a '1']; Then the IRS = $ (echo "$ i * $ resolution" | BC) jRes = $ (resonant "$ j * $ resolution" | bc) "some_text $ iRes $ jRes 15.95cm" echoed    

Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -