Pure Pursuit

Hi there,
I have been working on a Pure Pursuit code. I understand the concepts of PP, and how to use it. However, I am using the math from someone else’s code. Previously, I got it to work fine for me, but when I tried to do it again, it showed an error with int R4. The error pretty much says that R4 is undefined and it cannot take the square root. I am using a C++ compiler for all my debugging because it does not work for me to have V5 or V5pro downloaded. I think the error may be in the A8 B8 C4 and D4 lines. Can anyone help? I understand that this is not a very usual format for PP.

int x2 = 48;
int y2 = 24;
int x3 = 24;
int y3 = 24;
int x11 = 0;
int y11 = 0;
int x14 = 72;
int y14 = 0;

int g = 0;
int o = g-0.25;
int v = o-0.125;
int x15 = (((1-o)*(1-o)*(1-o))*(x11))+(3*o)*((1-o)*(1-o))*x3+((3*o)*(3*o))*(x2)+(o*o*o)*(x14);
int y15 = (((1-o)*(1-o)*(1-o))*(y11))+(3*o)*((1-o)*(1-o))*y3+((3*o)*(3*o))*(y2)+(o*o*o)*(y14);
int x16 = (((1-v)*(1-v)*(1-v))*(x11))+(3*v)*((1-v)*(1-v))*x3+((3*v)*(3*v))*(x2)+(v*v*v)*(x14);
int y16 = (((1-v)*(1-v)*(1-v))*(y11))+(3*v)*((1-v)*(1-v))*y3+((3*v)*(3*v))*(y2)+(v*v*v)*(y14);
int x17 = (((1-g)*(1-g)*(1-g))*(x11))+(3*g)*((1-g)*(1-g))*x3+((3*g)*(3*g))*(x2)+(g*g*g)*(x14);
int y17 = (((1-g)*(1-g)*(1-g))*(y11))+(3*g)*((1-g)*(1-g))*y3+((3*g)*(3*g))*(y2)+(g*g*g)*(y14);

int A8 = (x15*(y16-y17))-(y15*(x16-x17))+((x16)*(y17))-((x17)*(y16));
int B8 = (((x15)*(x15))+((y15)*(y15)))*(y17-y16)+(((x16)*(x16))+((y16)*(y16)))*(y15-y17)+(((x17)*(x17))+((y17)*(y17)))*(y16-y15);
int C4 = (((x15)*(x15))+((y15)*(y15)))*(y16-y17)+(((x16)*(x16))+((y16)*(y16)))*(y17-y15)+(((x17)*(x17))+((y17)*(y17)))*(y15-y16);
int D4 = (((x15)*(x15))+((y15)*(y15)))*(y16*x17-y17*x16)+(((x16)*(x16))+((y16)*(y16)))*(y17*x15-y15*x17)+(((x17)*(x17))+((y17)*(y17)))*(y15*x16-y16*x15);

int x18 = -((B8)/2*A8);
int y18 = -((C4)/2*A8);
int R4 = sqrt(((B8*B8)+(C4*C4)-4*A8*D4)/(4*(A8*A8)));

// Power Calculations
int Power = ((R4-9)/(R4+9))*11;


The type int can only store whole numbers (e.g. 1, 2, -5, 0, etc.). The sqrt function returns probably a double so that it can store decimal values (e.g. 3.1415, etc.). The compiler will do some implicit casting for you (e.g. your line int o = g-0.25 will have the value of 0 because g is set to 0 above, also, not really a good idea to have variables named o, O, I, or l, since they look like numbers and can be hard to read)