Here you can find the source of rotatePoint(double x0, double y0, double x, double y, double a)
Parameter | Description |
---|---|
x0 | coordinate x central point |
y0 | coordinate y central point |
x | coordinate x source point |
y | coordinate y source point |
a | angle of rotation in radians |
public static Point2D.Double rotatePoint(double x0, double y0, double x, double y, double a)
//package com.java2s; /*/*from w w w . java 2s .c o m*/ * Created on 01.02.2005 * * JDBReport Generator * * Copyright (C) 2005-2014 Andrey Kholmanskih * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ import java.awt.geom.Point2D; public class Main { /** * Turn of a point round other point counter-clockwise * * @param x0 coordinate x central point * @param y0 coordinate y central point * @param x coordinate x source point * @param y coordinate y source point * @param a angle of rotation in radians * @return result point */ public static Point2D.Double rotatePoint(double x0, double y0, double x, double y, double a) { Point2D.Double p = new Point2D.Double(); double sina = Math.sin(a); double cosa = Math.cos(a); p.x = x0 + (x - x0) * cosa + (y0 - y) * sina; p.y = y0 + (x - x0) * sina + (y - y0) * cosa; return p; } }