public BoxShape transform(double T[][]) {
   BoxShape bs = new BoxShape();
   bs.sxyz = LinAlg.copy(sxyz);
   bs.vertices = LinAlg.transform(T, vertices);
   bs.planes = LinAlg.transformPlanes(T, planes);
   return bs;
 }
  public void addLayer(VisLayer layer, double fviewport[]) {
    FPosition fpos = new FPosition();
    fpos.layer = layer;
    fpos.fviewport = LinAlg.copy(fviewport);
    fposes.add(fpos);

    vc.draw();
  }
Esempio n. 3
0
  public static void mixture() {
    Graph g = new Graph();

    int cnt = 5;

    for (int i = 0; i < cnt; i++) {
      GXYTNode gn = new GXYTNode();
      gn.init = new double[] {i, 0, 0};
      gn.state = LinAlg.copy(gn.init);
      gn.truth = new double[3];
      g.nodes.add(gn);

      if (i > 0) {
        double sig = 0.06;

        // wheel slippage mode
        GXYTEdge ge1 = new GXYTEdge();
        ge1.z = new double[] {0, 0, 0};
        ge1.P = LinAlg.diag(new double[] {sig, sig, sig});
        ge1.nodes = new int[] {i - 1, i};

        // nominal odometry
        GXYTEdge ge2 = new GXYTEdge();
        ge2.z = new double[] {1, 0, 0};
        ge2.P = LinAlg.diag(new double[] {sig, sig, sig});
        ge2.nodes = new int[] {i - 1, i};

        GEdgeMixture ge = new GEdgeMixture(new GEdge[] {ge1, ge2}, new double[] {0.05, 0.95});
        g.edges.add(ge);
      }
    }

    if (true) {
      GXYTEdge ge = new GXYTEdge();
      ge.z = new double[] {cnt, 0, 0};
      ge.P = LinAlg.diag(new double[] {0.1, 0.1, 0.1});
      ge.nodes = new int[] {0, g.nodes.size() - 1};
      g.edges.add(ge);
    }

    try {
      g.write("mixture.graph");
    } catch (IOException ex) {
      System.out.println("ex: " + ex);
    }
  }
Esempio n. 4
0
  public void read(StructureReader ins) throws IOException {
    int ncomponents = ins.readInt();
    components = new GEdge[ncomponents];
    weights = new double[ncomponents];

    for (int i = 0; i < components.length; i++) {
      weights[i] = ins.readDouble();
      String cls = ins.readString();
      components[i] = (GEdge) ReflectUtil.createObject(cls);
      ins.blockBegin();
      components[i].read(ins);
      ins.blockEnd();
    }

    attributes = Attributes.read(ins);

    nodes = LinAlg.copy(components[0].nodes);
  }
Esempio n. 5
0
  /** Components should all be of the same edge type. Weights should sum to 1. * */
  public GEdgeMixture(GEdge components[], double weights[]) {
    this.components = components;
    this.weights = weights;

    double total = 0;
    assert (components.length == weights.length);
    for (int i = 0; i < components.length; i++) {
      total += weights[i];
      assert (components[i].getClass().equals(components[0].getClass()));

      assert (components[i].nodes.length == components[0].nodes.length);
      for (int j = 0; j < components[0].nodes.length; j++) {
        assert (components[i].nodes[j] == components[0].nodes[j]);
      }
    }

    assert (total >= 0.99 && total <= 1.01);

    this.nodes = LinAlg.copy(components[0].nodes);
  }
  public BoxShape(double sxyz[]) {
    this.sxyz = LinAlg.copy(sxyz);
    planes = new ArrayList<double[]>();
    vertices = new ArrayList<double[]>();

    // create planes and vertices
    planes.add(new double[] {-1, 0, 0, -sxyz[0] / 2});
    planes.add(new double[] {1, 0, 0, -sxyz[0] / 2});

    planes.add(new double[] {0, -1, 0, -sxyz[1] / 2});
    planes.add(new double[] {0, 1, 0, -sxyz[1] / 2});

    planes.add(new double[] {0, 0, -1, -sxyz[2] / 2});
    planes.add(new double[] {0, 0, 1, -sxyz[2] / 2});

    for (int i = -1; i < 2; i += 2)
      for (int j = -1; j < 2; j += 2)
        for (int k = -1; k < 2; k += 2)
          vertices.add(new double[] {i * sxyz[0] / 2, j * sxyz[1] / 2, k * sxyz[2] / 2});
  }
Esempio n. 7
0
  public static void nomixture() {
    Graph g = new Graph();

    int cnt = 5;

    double u = 0.95;
    double sig = 0.1075;

    for (int i = 0; i < cnt; i++) {
      GXYTNode gn = new GXYTNode();
      gn.init = new double[] {i, 0, 0};
      gn.state = LinAlg.copy(gn.init);
      g.nodes.add(gn);

      if (i > 0) {
        GXYTEdge ge = new GXYTEdge();
        ge.z = new double[] {0.95, 0, 0};
        ge.P = LinAlg.diag(new double[] {sig, sig, sig});
        ge.nodes = new int[] {i - 1, i};
        g.edges.add(ge);
      }
    }

    if (true) {
      GXYTEdge ge = new GXYTEdge();
      ge.z = new double[] {0, 0, 0};
      ge.P = LinAlg.diag(new double[] {0.1, 0.1, 0.1});
      ge.nodes = new int[] {0, g.nodes.size() - 1};
      g.edges.add(ge);
    }

    try {
      g.write("nomixture.graph");
    } catch (IOException ex) {
      System.out.println("ex: " + ex);
    }
  }