コード例 #1
0
 // A function to rotate a vector
 public void rotateVector(PVector v, float theta) {
   float m = v.mag();
   float a = v.heading2D();
   a += theta;
   v.x = m * PApplet.cos(a);
   v.y = m * PApplet.sin(a);
 }
コード例 #2
0
 // Wraparound
 public void borders() {
   if (loc.x < -r) loc.x = width + r;
   if (loc.y < -r) loc.y = height + r;
   if (loc.x > width + r) loc.x = -r;
   if (loc.y > height + r) loc.y = -r;
 }