Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import android.graphics.Point;
import android.graphics.PointF;

public class Main {

    public static PointF rotatePoint(PointF point, PointF centerPoint, float rotate) {
        float x = point.x;
        float y = point.y;
        float sinA = (float) Math.sin(Math.toRadians(rotate));
        float cosA = (float) Math.cos(Math.toRadians(rotate));
        float newX = centerPoint.x + (x - centerPoint.x) * cosA - (y - centerPoint.y) * sinA;
        float newY = centerPoint.y + (y - centerPoint.y) * cosA + (x - centerPoint.x) * sinA;
        return new PointF(newX, newY);
    }

    public static Point rotatePoint(Point point, Point centerPoint, float rotate) {
        float x = point.x;
        float y = point.y;
        float sinA = (float) Math.sin(Math.toRadians(rotate));
        float cosA = (float) Math.cos(Math.toRadians(rotate));
        float newX = centerPoint.x + (x - centerPoint.x) * cosA - (y - centerPoint.y) * sinA;
        float newY = centerPoint.y + (y - centerPoint.y) * cosA + (x - centerPoint.x) * sinA;
        return new Point((int) newX, (int) newY);
    }
}