Hit detection madness

Hello,

    I am Brian Washechek, a 28 year old student at Casper College. Please look at this code! It's from Force Disruptor 2,

a sequel to a game i wrote a long, long time ago ( i’m thinking like 7 years). I’ll keep on attempting to write code
for this if you would take a look tese couple of lines of code! This is a sequel to Force Disruptor (the original), that got lost a long time ago. Seriously, Thank you for the help! ( I don’t understand what it wants for the nadas).
Brian Gregory Washechek the second(2nd)



//......
 int intersect(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, float &rx, float &ry)
{
  float a1, a2, b1, b2, c1, c2;
  float r1, r2 , r3, r4;
  float denom, offset, num;

  // Compute a1, b1, c1, where line joining points 1 and 2
  // is "a1 x + b1 y + c1 = 0".
  a1 = y2 - y1;
  b1 = x1 - x2;
  c1 = (x2 * y1) - (x1 * y2);

  // Compute r3 and r4.
  r3 = ((a1 * x3) + (b1 * y3) + c1);
  r4 = ((a1 * x4) + (b1 * y4) + c1);

  if ((r3 != 0) && (r4 != 0) && same_sign(r3, r4)){       
    return false;
  }

  // Compute a2, b2, c2
  a2 = y4 - y3;  
  b2 = x3 - x4;
  c2 = (x4 * y3) - (x3 * y4);

  r1 = (a2 * x1) + (b2 * y1) + c2;
  r2 = (a2 * x2) + (b2 * y2) + c2;

  if ((r1 != 0) && (r2 != 0) && (same_sign(r1, r2))){
       return false;  
  }

  denom = (a1 * b2) - (a2 * b1);

  if (denom == 0) {
    return DONT_INTERSECT;
  }

  if (denom < 0){ 
    offset = -denom / 2; 
  } 
  else {
    offset = denom / 2 ;
  
  }

  num = (b1 * c2) - (b2 * c1);
  if (num < 0){
    rx = (num - offset) / denom;
  } 
  else {
    rx = (num + offset) / denom;
  }

  num = (a2 * c1) - (a1 * c2);
  if (num < 0){
    ry = ( num - offset) / denom;
  } 
  else {
    ry = (num + offset) / denom;
  }

  // lines_intersect
  return DO_INTERSECT;
}
 //......
float nada1=1,nada2=1;
if (intersect(wallX*-cos(wallRot*),wallY*-sin(wallRot*),
                 wallX*+cos(wallRot*),wallY*+sin(wallRot*),
                  FDX-cos(FDA),FDY-sin(FDA)+9,
                  FDX+cos(FDA)+1,FDY+sin(FDA)+.8,
                        nada1,nada2))

:confused::confused:

It doesn’t want anything for the nadas. Any value they have before being passed by reference into the function is overwritten by the value they have coming out. It’s probably why it’s “nada” as in 0. You could just as well leave them uninitialized.

The function could use more descriptive variables, though.