Advertisement

(十二)利用processing模拟现实中的力

阅读量:

对现实世界中力学现象进行图形化模拟

动态物体类别:

复制代码
    //移动的物体
    class Mover{
      PVector location;         //物体的位置
      PVector velocity;         //物体的速度
      PVector acceleration; //物体的加速度
      float mass;                 //物体的质量
      float G;                       //万有引力常量,对于常量用大小为 1 表示
      Mover(float m_, float x_, float y_){
        location = new PVector(x_, y_);
        velocity = new PVector(0, 0);
        acceleration = new PVector(0, 0);
        mass = m_;
        G = 1;
      }
      Mover(){
        location = new PVector(random(width), random(height));
        velocity = new PVector(0, 0);

全部评论 (0)

还没有任何评论哟~