title: Sorting points by their polar angle in Java
body: <p>I'm using Graham scan algorithm to find the convex-hull of set of points 
  I'm trying to sort the points by their polar angle but I have no idea how to do it (I've already sorted the set of points by their Y coordinates).</p>
  
  <p>What I've already wrote is like this:</p>
  
  <pre><code>public double angle(Coord o, Coord a)
  {
      return Math.atan((double)(a.y - o.y) / (double)(a.x - o.x));
  }
  </code></pre>
  
  <p>where <code>Coord</code> is the class where I have X and Y coordinates as <code>double</code>.</p>
  
  <p>I also looked at one of the similar posts in Stack Overflow where someone had tried to implement this angle with C++, but I don't understand <code>qsqrt</code>. Do we have something like this in Java? </p>
  
  <pre><code>qreal Interpolation::dp(QPointF pt1, QPointF pt2)
  {
      return (pt2.x()-pt1.x())/qSqrt((pt2.x()-pt1.x())*(pt2.x()-pt1.x()) + (pt2.y()-pt1.y())*(pt2.y()-pt1.y()));
  }
  </code></pre>
  
  <p>I'll be glad if anyone can help me.</p>