title: How to find the negative inverse of a number?
body: <p>I have two points A and B and a population of points, and I would like to find the distance from each and every point to the line AB.</p>
  
  <p>I first get the slope of the line, and then its Y intercept. And following <a href="https://www.youtube.com/watch?v=iATjsfAX8yc" rel="nofollow noreferrer">Distance between point &amp; line</a>, at second <a href="https://youtu.be/iATjsfAX8yc?t=47s" rel="nofollow noreferrer">00:48</a> it states that we need the negative inverse of the slope (number).</p>
  
  <p>I would like a function that takes any number, and returns the negative inverse of it. Something like <code>let inverseOfSlope = getInverse(slope);</code> Please and thanks</p>
  
  <pre><code>getDistance(PointA: Object, PointB: Object, Target: Object)
  {
      // find slope of the line
      let slope = (PointA.y - PointB.y) / (PointA.x - PointB.x)
  
      // find y intercept
      let yIntercept = PointA.y + ((-1 * slope) * PointA.x)
  
      // find inverse negative of the slope
      let newSlope = -1 * getInverse(slope);
  
      // find new y-intercept
      let NewYintercept = PointA.y + ((-1 * newSlope) * PointA.x)
  
      // get point of intersection between the two lines
      // by solving the two equations equal to each other
  
      // calculate distance between target and point of intersection
      // easy
  
      // return result
  }
  </code></pre>