7
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

三角関数で円周運動

Posted at

デモ:http://codepen.io/mo4_9/pen/amvxKE

角度をラジアンに変換し、
degree * Math.PI / 180

それを三角関数に渡して、半径をかける

座標を計算する
calcBallPos(radius, space, speed) {
  speed = speed || 1.0;
  const rad = ( this.degree * speed + this.diameter + space ) * Math.PI / 180;
  const x = radius * Math.sin(rad);// X座標 = 半径 x Sinθ
  const y = radius * Math.cos(rad);// Y座標 = 半径 x Cosθ

  return {'x':x, 'y':y};
}
角度を更新する
render() {

  this.degree++;

  const pos1 = this.calcBallPos(100, 10, 2);

  this.sphere.position.set(pos1['x'], pos1['y'], 0);
  
}

参考
sin関数

7
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?