Java Graphics Rotate rotatePoint2D(final Point aPoint, final float aDeg)

Here you can find the source of rotatePoint2D(final Point aPoint, final float aDeg)

Description

rotate Point D

License

Open Source License

Declaration

public static Point rotatePoint2D(final Point aPoint, final float aDeg) 

Method Source Code

//package com.java2s;
/* /*w w w. ja va  2  s. co m*/
 *  Copyright 2012 Samuel Taylor
 * 
 *  This file is part of darkFunction Editor
 *
 *  darkFunction Editor is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  darkFunction Editor is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
    
 *  You should have received a copy of the GNU General Public License
 *  along with darkFunction Editor.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.awt.Point;

public class Main {
    public static Point rotatePoint2D(final Point aPoint, final float aDeg) {
        double a = Math.toRadians(aDeg);
        Point p = new Point();
        p.x = (int) ((aPoint.x * Math.cos(a)) - (aPoint.y * Math.sin(a)));
        p.y = (int) ((aPoint.y * Math.cos(a)) + (aPoint.x * Math.sin(a)));

        return p;
    }
}

Related

  1. rotatePoint(int x, int y, int xC, int yC, float angle)
  2. rotatePoint(Point center, Point p, double angle)
  3. rotatePoint(Point point, Point centerPoint, double angle)
  4. rotatePoint(Point reference, Point toRotate, int degrees)
  5. rotatePoint(Point target, Point origin, double theta)
  6. rotateRAD(double x, double y, double a)
  7. rotateShape(final Shape base, final double angle, final float x, final float y)
  8. rotateToZero(Vector points, Vector newPoints)