title: Distance between a line and a point in Objective-C?
body: <p>I have 2 class :</p>
  
  <pre><code>// point : (x, y)
  @interface ICPoint : NSObject {
      NSInteger x;
      NSInteger y;
  }
  
  // line : y= ax + b
  @interface ICLine : NSObject {
      float a;
      float b;
  }
  </code></pre>
  
  <p>and this method:</p>
  
  <pre><code>// return the distance between a line and a point
  -(NSInteger) distance:(ICPoint *)point {
      return fabs(-a*point.x +point.y - b) / sqrt(a*a + 1);
  }
  </code></pre>
  
  <p>The formula seems right (based on wikipedia), but the results are wrong... why ?<br>
  Thanks !</p>
  
  <p>Edit:</p>
  
  <pre><code>ICLine *line1 = [[ICLine alloc] initWithA:0.60 andB:11.25];
  ICLine *line2 = [[ICLine alloc] initWithA:0.61 andB:-2.85];
  
  ICPoint *point = [[ICPoint alloc] initWithX:41 andY:22];
  
  [line1 distance:point]; // give 11, it's ok.
  [line2 distance:point]; // give 24, it should be ~0...
  </code></pre>