Here you can find the source of rotatePoint(Point target, Point origin, double theta)
Parameter | Description |
---|---|
target | _more_ |
origin | _more_ |
theta | _more_ |
public static Point rotatePoint(Point target, Point origin, double theta)
//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))); } }