I use Graham's scanning algorithm to find the convex hull of many points. I try to sort the points by their polar angle, but I have no idea how to do this (I already sorted the many points by their Y coordinates).
What I have already written is as follows:
public double angle(Coord o, Coord a) { return Math.atan((double)(ay - oy) / (double)(ax - ox)); }
where Coord is the class in which I have the X and Y coordinates as double .
I also looked at one of these entries in Stack Overflow, where someone was trying to implement this angle with C ++, but I don't understand qsqrt . Do we have something similar in Java?
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())); }
I would be glad if someone can help me.
Navid koochooloo
source share