LoginSignup
8
6

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);
}
8
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
8
6