计算某点绕中心点旋转一个角度后的坐标
开发中碰到一个坐标转换的算法问题,终于解决了,在此分享下。
java代码实现如下:
private static Point calcNewPoint(Point p, Point pCenter, float angle) {// calc arc float l = (float) ((angle * Math.PI) / 180);//sin/cos valuefloat cosv = (float) Math.cos(l);float sinv = (float) Math.sin(l);// calc new pointfloat newX = (float) ((p.x - pCenter.x) * cosv - (p.y - pCenter.y) * sinv + pCenter.x);float newY = (float) (-(p.x - pCenter.x) * sinv + (p.y - pCenter.y) * cosv + pCenter.y);return new Point((int) newX, (int) newY);}?