/** * Given a working point and a reference point, rotate the working point by the given angle around * the reference point. * * @param p * @param angle * @param around * @return */ private static BitPoint rotatePoint(BitPoint p, float angle, BitPoint around) { double s = Math.sin(angle); double c = Math.cos(angle); // translate point back to origin: p.x -= around.x; p.y -= around.y; // rotate point double xnew = p.x * c - p.y * s; double ynew = p.x * s + p.y * c; // translate point back: p.x = (float) (xnew + around.x); p.y = (float) (ynew + around.y); return p; }