title: (java) Decide if a line intercepts a circle
body: <p>So, I need to write a program that decides whether a line intercepts a circle or not.  Specific interception coordinates are not required, and simply being touching the circle or being tangent to it causes interception as well.  Apologies if this has been asked before, but I couldn't find anything that suited my problem.  Maybe I didn't look hard enough.</p>
  
  <pre><code>   import java.util.Scanner;
  public class LineCircle_Intersection {
  
  public static void main(String[] args) {
      Scanner in = new Scanner(System.in);
  
      double p1x, p2x, p1y, p2y, cx, cy, r;
  
      System.out.print("Enter p1x: ");
      p1x = in.nextDouble();
      System.out.print("Enter p1y: ");
      p1y = in.nextDouble();
      System.out.print("Enter p2x: ");
      p2x = in.nextDouble();
      System.out.print("Enter p2y: ");
      p2y = in.nextDouble();
      System.out.print("Enter cx: ");
      cx = in.nextDouble();
      System.out.print("Enter cy: ");
      cy = in.nextDouble();
      System.out.print("Enter r: ");
      r = in.nextDouble();
  
      if ((p1x - cx &lt; r) &amp;&amp; (p1y - cy &lt; r))
          System.out.println("The line intersects the circle.");
      else if ((p2x - cx &lt; r) &amp;&amp; (p2y - cy &lt; r))
          System.out.println("The line intersects the circle.");
      else
          System.out.println("The line does not intersect the circle.");
  
  }
  
  }
  </code></pre>
  
  <p>I've been working on an alternate route that uses line and circle formulas instead of the input points, but it's kind of a mess and I'm not sure where I'm going with it.</p>