title: Function to check a point is on a straight line
body: <p>I have the coordinates of a point <em>pos = (x, y)</em>, and I need to check if it is a part of a straight line which passes trought two points <em>p1 = (x1, y1), p2 = (x2, y2)</em>.
  The formula that i'm using is y - y1 = ((x - x1)/(x2 - x1)) * (y2 - y1), and the code is:</p>
  
  <pre><code>        if pos[1] - p1[1] - 10 &lt;= ((pos[0] - p1[0]) / (p2[0] - p1[0])) * (p2[1] - p1[1]) &lt;= pos[1] - p1[1] + 10:
              return True
  </code></pre>
  
  <p>While I was testing it, I noticed that the straight line the slope is the opposite.
  <a href="https://i.stack.imgur.com/Ubrlf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ubrlf.png" alt="image"></a></p>
  
  <p>I got this by check every point of the canvas (using tkinter):</p>
  
  <pre><code>    p1 = (313, 215)
      p2 = (92, 44)
  
      for x in range(0, 400):
          for y in range(0, 300):
              if y - p1[1] - 5 &lt;= ((x - p1[0]) / (p2[0] - p1[0])) * (p2[1] - p1[1]) &lt;= y - p1[1] + 5:
                  canvas.create_oval(x, y, x, y)
  </code></pre>
  
  <p>The biggest one is the line which is represented by the equation above, the hand drawn one is what I want.</p>
  
  <p>I tried also to test it on geogebra, but there all works properly...what am I missimg?</p>