Java Graphics Rotate rotatePoint(Point target, Point origin, double theta)

Here you can find the source of rotatePoint(Point target, Point origin, double theta)

Description

_more_

License

Open Source License

Parameter

Parameter Description
target _more_
origin _more_
theta _more_

Return

_more_

Declaration

public static Point rotatePoint(Point target, Point origin, double theta) 

Method Source Code

//package com.java2s;
/**/* w  w  w. java 2 s. c  om*/
* Copyright (c) 2008-2015 Geode Systems LLC
* This Software is licensed under the Geode Systems RAMADDA License available in the source distribution in the file 
* ramadda_license.txt. The above copyright notice shall be included in all copies or substantial portions of the Software.
*/

import java.awt.*;

public class Main {
    /**
     * _more_
     *
     * @param target _more_
     * @param origin _more_
     * @param theta _more_
     *
     * @return _more_
     */
    public static Point rotatePoint(Point target, Point origin, double theta) {
        Point ret = rotatePoint(new Point(target.x - origin.x, target.y - origin.y), theta);
        ret.x += origin.x;
        ret.y += origin.y;

        return ret;
    }

    /**
     * _more_
     *
     * @param target _more_
     * @param theta _more_
     *
     * @return _more_
     */
    public static Point rotatePoint(Point target, double theta) {
        return (new Point((int) (target.x * Math.cos(theta) - target.y * Math.sin(theta) + 0.5),
                (int) (target.x * Math.sin(theta) + target.y * Math.cos(theta) + 0.5)));
    }
}

Related

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