为什么椭圆的这种简单旋转过度旋转并扭曲尺寸?

Jon*_*com 2 javascript math geometry shapes kinematics

三个不同的人告诉我这是旋转椭圆的正确方法:

// Get current position on the elliptical path.
var x = Math.cos( this.timer.delta() * this.speed ) * ( this.pathWidth / 2 );
var y = Math.sin( this.timer.delta() * this.speed ) * ( this.pathHeight / 2 );

// Rotate the ellipse.
var newX = x * Math.cos( this.angle ) - y * Math.sin( this.angle );
var newY = x * Math.sin( this.angle ) - y * Math.cos( this.angle );
Run Code Online (Sandbox Code Playgroud)

我正在使用计时器,以便椭圆路径上的位置随时间循环.

当this.angle = 0时,路径没有变化.

但是当this.angle大于0时,椭圆不会保持它的比例.它被压扁和拉扯.并且单度增量之间的差异非常严重.

编辑1:

另外,我希望this.angle == 0时的路径与180,360,540,720等时的路径相同.

但他们都不同.

编辑2:

尽管此后已经纠正了拼写错误,但行为相同.

编辑3:

通过从度数转换为弧度并使用它们来解决行为.

像这样:

this.angleRadians = this.angle * ( Math.PI / 180 );
Run Code Online (Sandbox Code Playgroud)

Ign*_*ams 5

你的newX等式是错误的.你错过了y.