旋转椭圆而不进行动态观察



我有一个自定义椭圆,它有一个旋转方法:

 import com.badlogic.gdx.math.Vector2;
public class BetterEllipse {
    float centerx,centery,width,height;
    int pointAmount;
    //float vector array
    Vector2[] border;
    BetterEllipse(float cneterX,float centerY,float width_, float height_)
    {
        centerx=cneterX; centery=centerY;
        width=width_; height=height_;
        pointAmount=360;
        border=new Vector2[pointAmount];
        for(int n=0;n<pointAmount;n++)
        {
            double x=cneterX +(width_/2*Math.cos(n));
            double y=centerY+  (height_/2*Math.sin(n));
            border[n]=new Vector2((float)x,(float)y);
        }
    }
    /**angle > 0 - rotates counter-clock, angle < 0 - rotate clock*/
    public void rotate(float angle)
    {
        for(Vector2 point:border)
        {
            float newX=(float) ((point.x)*Math.cos(angle)-(point.y)*Math.sin(angle));
            float newY=(float) ((point.x)*Math.sin(angle)+(point.y)*Math.cos(angle));
            //after
            point.x=newX;
            point.y=newY;   
        }

    }
}

椭圆会旋转,但也会围绕点0,0旋转。我想我必须把centex,centey放在旋转()中,但不知道怎么做。

减去后旋转

中心=1/2*(中心x+中心y)

然后将其再次添加到结果中。

最新更新