1

I'm trying to implement rotation matrix. But a have a very strange effect: How it look like

This is my code:

public void rotation(PointF point, double a) {

    point.x = (point.x - 400) * Math.cos(a) - (point.y - 300) * Math.sin(a)
            + 400;
    point.y = (point.x - 400) * Math.sin(a) + (point.y - 300) * Math.cos(a)
            + 300;
}

In result a have a falling point in coordinates 400,300.

What is wrong? I want point to move by circle? How I can do better?

4

1 回答 1

6

不应该是这样吗

double x = point.x * Math.cos(a) - point.y * Math.sin(a);
double y = point.x * Math.sin(a) + point.y * Math.cos(a);
point.x = x;
point.y = y;

防止过早修改point.x?

于 2013-04-26T18:59:00.183 回答