Esempio n. 1
0
 @Override
 public void subtract(Vector v) {
   verifyVectorSizesMatch(this, v);
   for (int i = 0; i < getSize(); i++) {
     setValue(i, this.getValue(i) - v.getValue(i));
   }
 }
Esempio n. 2
0
 @Override
 public float dotProduct(Vector v) {
   verifyVectorSizesMatch(this, v);
   float dotProduct = 0.0f;
   for (int i = 0; i < getSize(); i++) {
     dotProduct += this.getValue(i) * v.getValue(i);
   }
   return dotProduct;
 }
Esempio n. 3
0
 @Override
 public void run() {
   float temp;
   for (int i = startIndex; i <= endIndex; i++) {
     temp = 0.0f;
     for (int j : m.getNonZeroRowIndecies(i)) {
       temp += getValue(j) * m.getValue(i, j);
     }
     result.setValue(i, temp);
   }
   cdl.countDown();
 }
Esempio n. 4
0
  private boolean check(float px, float py) {
    Vector p = new Vector(px, py);
    int v1 = (int) p.subtract(a).cross(b.subtract(a));
    int v2 = (int) p.subtract(b).cross(c.subtract(b));
    int v3 = (int) p.subtract(c).cross(d.subtract(c));
    int v4 = (int) p.subtract(d).cross(a.subtract(d));

    if (v1 <= 0 && v2 <= 0 && v3 <= 0 && v4 <= 0) {
      return true;
    } else {
      return false;
    }
  }
Esempio n. 5
0
  @Override
  public void draw() {
    // draw the rectangle surrounding us.
    Configuration.getDisplayModel().drawRectangle(new Vector(100, 100), new Vector(200, 200));

    // Draw the rectangle to indicate the P node.
    Configuration.getDisplayModel().drawRectangle(_p.subtract(new Vector(3, 3)), new Vector(6, 6));
    for (int x = 0; x < 600; x = x + 5) {
      for (int y = 0; y < 600; y = y + 5) {
        if (check(x, y)) {
          // if it is inside the block, draw some shit
          Configuration.getDisplayModel().drawRectangle(new Vector(x, y), new Vector(5, 5));
        }
      }
    }
  }
Esempio n. 6
0
 private void verifyVectorSizesMatch(Vector v1, Vector v2) {
   if (v1.getSize() != v2.getSize()) {
     throw new IllegalArgumentException("The vectors must be of the same size");
   }
 }
Esempio n. 7
0
 @Override
 public void mouseMoved(int mouseX, int mouseY) {
   // move our object.
   _p.X = mouseX;
   _p.Y = mouseY;
 }
Esempio n. 8
0
 @Override
 public void step() {
   int val = (int) _p.subtract(b).cross(c.subtract(b));
 }