Exemplo n.º 1
0
 public void mousecoord(Atom[] args) {
   mousecoord = new float[] {args[0].toFloat(), args[1].toFloat(), args[2].toFloat()};
   double r =
       Math.sqrt(
           (args[0].toFloat() * args[0].toFloat()) + (args[1].toFloat() * args[1].toFloat()));
   double d = Math.atan2(args[1].toFloat(), args[0].toFloat());
 }
Exemplo n.º 2
0
  /* initialize pattern bezier elements with random values */
  public void randomizeElements(float f, float r, boolean all) {

    for (int p = 0; p < pNumMax; p++) {
      if (activated[p] || all) {
        if (all || !animationQueue || (animationQueue && p == theActive[animationQueuePointer])) {
          //					post("p "+p+"   animationQueue "+animationQueue+"  animationQueuePointer
          // "+animationQueuePointer+
          //							"   theActive[animationQueuePointer]) "+theActive[animationQueuePointer]);
          for (int e = 0; e < eNumMax; e++) {

            // randomize bezier point noise
            for (int b = 0; b < bNum; b++) {
              // set noise to 0 if element is not active (<eNum)
              if (dice(f))
                patternNoise[p][e][b][0] = (e < eNum) ? (float) Math.random() * 2 - 1.f : 0.f;
              else if (dice(r)) patternNoise[p][e][b][0] = 0.f;
              if (dice(f))
                patternNoise[p][e][b][1] = (e < eNum) ? (float) Math.random() * 2 - 1.f : 0.f;
              else if (dice(r)) patternNoise[p][e][b][1] = 0.f;
              if (dice(f)) patternNoise[p][e][b][2] = 0.f;
              else if (dice(r)) patternNoise[p][e][b][2] = 0.f;
            }
          }
        }
      }
    }
  }
Exemplo n.º 3
0
 public void update() {
   rad += increment;
   if (rad > (Math.PI * 2)) {
     rad = 0.0;
   }
   coords[0] = 0.8 * Math.cos(rad);
   coords[1] = 0.8 * Math.sin(rad);
 }
Exemplo n.º 4
0
    public boolean stopdrag(float[] mc) {
      double r = Math.sqrt((mc[0] * mc[0]) + (mc[1] * mc[1]));
      double d = Math.atan2(mc[1], mc[0]);

      polar[0] = (Math.round(d * 100.00)) / 100.00;
      polar[1] = r;

      return r > 0.8;
    }
Exemplo n.º 5
0
    public double getRad() {

      if (rad > Math.PI) {
        // if below
        return (Math.round((rad - (Math.PI * 2)) * 100.00)) / 100.00;
      } else {
        return Math.round(rad * 100.00) / 100.00;
      }
    }
Exemplo n.º 6
0
    SeqNode(float _x, float _y, float _z, float _size, String _name) {
      coords = new float[] {_x, _y, _z};

      double r = Math.sqrt((_x * _x) + (_y * _y));
      double d = Math.atan2(_y, _x);

      polar = new double[] {d, r};
      polar[0] = (Math.round(d * 100.00)) / 100.00;

      size = _size;
      hover = false;
      triggered = false;
      selected = false;
      name = _name;
    }
Exemplo n.º 7
0
    private boolean detectHit(float[] mc) {

      if ((mc[0] < 0 && coords[0] < 0)
          || (mc[0] > 0 && coords[0] > 0) && (mc[1] < 0 && coords[1] < 0)
          || (mc[1] > 0 && coords[1] > 0) && (mc[2] < 0 && coords[2] < 0)
          || (mc[2] > 0 && coords[2] > 0)) {

        double dx = Math.pow((mc[0] + 100) - (coords[0] + 100), 2);
        double dy = Math.pow((mc[1] + 100) - (coords[1] + 100), 2);
        double dz = Math.pow((mc[2] + 100) - (coords[2] + 100), 2);
        double vLength = Math.sqrt(dx + dy + dz);

        if ((vLength) < (size + 0.05)) {
          return true;
        }
      }

      return false;
    }
Exemplo n.º 8
0
 public void randomizeWidth(float f, float r, boolean all) {
   for (int p = 0; p < pNumMax; p++) {
     if (activated[p] || all) {
       if (all || !animationQueue || (animationQueue && p == theActive[animationQueuePointer])) {
         for (int e = 0; e < eNumMax; e++) {
           // randomize width noise
           if (dice(f)) widthNoise[p][e] = (float) Math.random() * 2 - 1.f;
           else if (dice(r)) widthNoise[p][e] = 0.f;
         }
       }
     }
   }
 }
Exemplo n.º 9
0
  private float[] perpendicularVector(float[] point1, float[] point2) {

    float[] ofv = {0, 0, 0};

    float x = point2[0] - point1[0];
    float y = point2[1] - point1[1];
    float z = point2[2] - point1[2];

    float c = (float) Math.sqrt(x * x + y * y + z * z);
    ofv[0] = -y / c;
    ofv[1] = x / c;
    ofv[2] = z / c;

    return ofv;
  }
Exemplo n.º 10
0
 /* translate from 0 to 1, to a half circle
  * 0.0 = 0
  * 0.5 = 1
  * 1.0 = 0
  */
 private float halfCircle(float t) {
   return (float) Math.sin(t * 3.1415927f);
 }
Exemplo n.º 11
0
 /*
  * Bezier : Computes Bernstain
  *
  * @param {Integer} i - the i-th index
  *
  * @param {Integer} n - the total number of points
  *
  * @param {Number} t - the value of parameter t , between 0 and 1
  */
 private float B(int i, int n, float t) {
   return (float) (fact(n) / (fact(i) * fact(n - i)) * Math.pow(t, i) * Math.pow(1 - t, n - i));
 }
Exemplo n.º 12
0
  /* chance function. return true if random value within threshold */
  private boolean dice(double f) {

    double v = Math.random();
    if (v < f) return true;
    else return false;
  }
Exemplo n.º 13
0
 public void resize(float[] mc) {
   double dx = Math.pow((mc[0] + 100) - (coords[0] + 100), 2);
   double dy = Math.pow((mc[1] + 100) - (coords[1] + 100), 2);
   double dz = Math.pow((mc[2] + 100) - (coords[2] + 100), 2);
   size = Math.sqrt(dx + dy + dz);
 }
Exemplo n.º 14
0
 Sweep() {
   rad = 0;
   increment = 0.01;
   coords = new double[] {0.8 * Math.cos(rad), 0.8 * Math.sin(rad), 0.0};
   origin = new double[] {0.0, 0.0, 0.0};
 }