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
スクリーンショット 2016-03-16 17.23.49.png

二次元平面上でパーティクルを動かし、それを三次元の球面上で動かすことを考えます。

単位ベクトルを使う

Mover.pde
void display() {
    // 位置に合わせて色を変える
    stroke(255 * location.x / width,255 * location.y / height,255 * location.z / width);
    strokeWeight(1);
    fill(175);

    
    PVector l = location.get();
    // 単位ベクトルにする
    l.normalize();
  // 球の半径だけ伸ばす
    l.mult(300);

  // 中心付近に移動
    l.add(width, 0, 0);

    point(l.x, l.y, l.z);
}
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?