2

これが楕円を回転させる正しい方法であると 3 人の異なる人から言われました。

// 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 );

楕円パス上の位置が時間とともに循環するように、タイマーを使用しています。

this.angle = 0 の場合、パスに変更はありません。

しかし、 this.angle が 0 より大きい場合、楕円はその比率を維持しません。つぶれて引っ張られます。そして、1度の増分の違いはかなり深刻です。

編集1:

また、 this.angle == 0 のときのパスは、180、360、540、720 などのときと同じになると思います。

しかし、それらはすべて異なります。

編集2:

その後修正されたタイプミスにもかかわらず、同じ動作。

編集3:

度からラジアンに変換し、代わりにそれらを使用することで解決された動作。

そのようです:

this.angleRadians = this.angle * ( Math.PI / 180 );
4

1 に答える 1

5

あなたのnewX方程式は間違っています。あなたが行方不明yです。

于 2012-10-15T06:02:36.383 に答える