I'm trying to come up with a work around to perform a few math functions for a script since bash apparently cannot do anything other than integer math (or can it even do that?).
The script I'm coming up with needs to write a series of macros which will eventually be used for a simulation program. I'm currently just trying to output positions of a particle source which are used as parameters of the macro.
The C++ Program I wrote is very simple, it takes in i and outputs x and y as such:
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
double i;
double theta = 11 * (3.1415926535897932384626/180);
cin >> i;
double b = 24.370;
double y = (b/i)*sin(theta);
double x = (b/i)*cos(theta);
cout << x << " " << y << endl;
return 0;
}
The script I'm writing outputs a bunch of stuff that has to do with the macros i'm trying to create, but the line I'm stuck on (labled as (1) ) needs to do something like this...
for i in {1..100}
do
echo "./a.out" #calling the C program
echo "$i" #entering i as input
x = first output of a.out, y = second output a.out #(1) Confused on how to do this part!
echo -n "/gps/position $x $y 0 27.7 cm" > mymacro.mac
done
I know there has to be a really easy way to do this but I'm not exactly sure what to do. I basically just need to use the output of a c program as variables in the script.