Package de.lmu.ifi.dbs.elki.math.linearalgebra

Examples of de.lmu.ifi.dbs.elki.math.linearalgebra.Vector


        if(poly == null) {
          continue;
        }
        SVGPath path = new SVGPath();
        for(Polygon ppoly : poly.getPolygons()) {
          Vector first = ppoly.get(0);
          double[] f = proj.fastProjectDataToRenderSpace(first.getArrayRef());
          path.moveTo(f[0], f[1]);
          for(Vector v : ppoly) {
            if(v == first) {
              continue;
            }
View Full Code Here


      DBIDs ids = clus.getIDs();

      if(ids.size() > 0) {
        Matrix covmat = clus.getModel().getCovarianceMatrix();
        NV centroid = clus.getModel().getMean();
        Vector cent = new Vector(proj.fastProjectDataToRenderSpace(centroid));

        // Compute the eigenvectors
        SortedEigenPairs eps = pcarun.processCovarMatrix(covmat).getEigenPairs();

        Vector[] pc = new Vector[eps.size()];
        for(int i = 0; i < eps.size(); i++) {
          EigenPair ep = eps.getEigenPair(i);
          Vector sev = ep.getEigenvector().times(Math.sqrt(ep.getEigenvalue()));
          pc[i] = new Vector(proj.fastProjectRelativeDataToRenderSpace(sev));
        }
        if(drawStyle != 0 || eps.size() == 2) {
          drawSphere2D(cnum, cent, pc);
        }
        else {
View Full Code Here

    for(int dim1 = 0; dim1 < pc.length - 1; dim1++) {
      for(int dim2 = dim1 + 1; dim2 < pc.length; dim2++) {
        for(int i = 1; i <= times; i++) {
          SVGPath path = new SVGPath();

          Vector direction1 = pc[dim1].times(KAPPA * i);
          Vector direction2 = pc[dim2].times(KAPPA * i);

          Vector p1 = cent.plusTimes(pc[dim1], i);
          Vector p2 = cent.plusTimes(pc[dim2], i);
          Vector p3 = cent.minusTimes(pc[dim1], i);
          Vector p4 = cent.minusTimes(pc[dim2], i);

          path.moveTo(p1);
          path.cubicTo(p1.plus(direction2), p2.plus(direction1), p2);
          path.cubicTo(p2.minus(direction1), p3.plus(direction2), p3);
          path.cubicTo(p3.minus(direction2), p4.minus(direction1), p4);
          path.cubicTo(p4.plus(direction1), p1.minus(direction2), p1);
          path.close();

          Element ellipse = path.makeElement(svgp);
          SVGUtil.addCSSClass(ellipse, EMBORDER + cnum);
          if(opacStyle == 1) {
View Full Code Here

    return true;
  }

  @Override
  public boolean endDrag(SVGPoint startPoint, SVGPoint dragPoint, Event evt, boolean inside) {
    Vector movingVector = new Vector(2);
    movingVector.set(0, dragPoint.getX() - startPoint.getX());
    movingVector.set(1, dragPoint.getY() - startPoint.getY());
    if(context.getSelection() != null) {
      updateDB(context.getSelection().getSelectedIds(), movingVector);
    }
    deleteChildren(rtag);
    return true;
View Full Code Here

          // Reverse anti-clockwise polygons.
          boolean reverse = (p.testClockwise() >= 0);
          Iterator<Vector> it = reverse ? p.descendingIterator() : p.iterator();
          while(it.hasNext()) {
            Vector v = it.next();
            out.writeCharacters(FormatUtil.format(v.getArrayRef(), ","));
            if(compat && (v.getDimensionality() == 2)) {
              out.writeCharacters(",500");
            }
            out.writeCharacters(" ");
          }
          out.writeEndElement(); // close coordinates
View Full Code Here

  protected void drawHullLines(int cnum, Vector cent, Polygon chres) {
    for(int i = 1; i <= times; i++) {
      SVGPath path = new SVGPath();
      for(int p = 0; p < chres.size(); p++) {
        Vector cur = cent.plusTimes(chres.get(p), i);
        path.drawTo(cur);
      }
      path.close();
      Element ellipse = path.makeElement(svgp);
      SVGUtil.addCSSClass(ellipse, EMBORDER + cnum);
View Full Code Here

  }

  protected Polygon makeHull(Vector[] pc) {
    ConvexHull2D hull = new ConvexHull2D();

    Vector diag = new Vector(0, 0);
    for(int j = 0; j < pc.length; j++) {
      hull.add(pc[j]);
      hull.add(pc[j].times(-1));
      for(int k = j + 1; k < pc.length; k++) {
        Vector q = pc[k];
        Vector ppq = pc[j].plus(q).timesEquals(MathUtil.SQRTHALF);
        Vector pmq = pc[j].minus(q).timesEquals(MathUtil.SQRTHALF);
        hull.add(ppq);
        hull.add(ppq.times(-1));
        hull.add(pmq);
        hull.add(pmq.times(-1));
      }
      diag.plusEquals(pc[j]);
    }
    diag.timesEquals(1.0 / Math.sqrt(pc.length));
    hull.add(diag);
View Full Code Here

      if(alpha >= Double.POSITIVE_INFINITY) {
        GrahamScanConvexHull2D hull = new GrahamScanConvexHull2D();

        for(DBID clpnum : ids) {
          double[] projP = proj.fastProjectDataToRenderSpace(rel.get(clpnum));
          hull.add(new Vector(projP));
        }
        Polygon chres = hull.getHull();

        // Plot the convex hull:
        if(chres != null && chres.size() > 1) {
          SVGPath path = new SVGPath(chres);
          // Approximate area (using bounding box)
          double hullarea = SpatialUtil.volume(chres);
          final double relativeArea = (projarea - hullarea) / projarea;
          final double relativeSize = (double) ids.size() / rel.size();
          opacity = Math.sqrt(relativeSize * relativeArea);

          Element hulls = path.makeElement(svgp);
          addCSSClasses(svgp, cnum, opacity);
          SVGUtil.addCSSClass(hulls, CLUSTERHULL + cnum);
          layer.appendChild(hulls);
        }
      }
      else {
        ArrayList<Vector> ps = new ArrayList<Vector>(ids.size());
        for(DBID clpnum : ids) {
          double[] projP = proj.fastProjectDataToRenderSpace(rel.get(clpnum));
          ps.add(new Vector(projP));
        }
        List<Polygon> polys = (new AlphaShape(ps, alpha * Projection.SCALE)).compute();
        for(Polygon p : polys) {
          SVGPath path = new SVGPath(p);
          Element hulls = path.makeElement(svgp);
View Full Code Here

  }

  protected Polygon makeHullComplex(Vector[] pc) {
    ConvexHull2D hull = new ConvexHull2D();

    Vector diag = new Vector(0, 0);
    for(int j = 0; j < pc.length; j++) {
      hull.add(pc[j]);
      hull.add(pc[j].times(-1));
      for(int k = j + 1; k < pc.length; k++) {
        Vector q = pc[k];
        Vector ppq = pc[j].plus(q).timesEquals(MathUtil.SQRTHALF);
        Vector pmq = pc[j].minus(q).timesEquals(MathUtil.SQRTHALF);
        hull.add(ppq);
        hull.add(ppq.times(-1));
        hull.add(pmq);
        hull.add(pmq.times(-1));
        for(int l = k + 1; l < pc.length; l++) {
          Vector r = pc[k];
          Vector ppqpr = ppq.plus(r).timesEquals(Math.sqrt(1 / 3.));
          Vector pmqpr = pmq.plus(r).timesEquals(Math.sqrt(1 / 3.));
          Vector ppqmr = ppq.minus(r).timesEquals(Math.sqrt(1 / 3.));
          Vector pmqmr = pmq.minus(r).timesEquals(Math.sqrt(1 / 3.));
          hull.add(ppqpr);
          hull.add(ppqpr.times(-1));
          hull.add(pmqpr);
          hull.add(pmqpr.times(-1));
          hull.add(ppqmr);
          hull.add(ppqmr.times(-1));
          hull.add(pmqmr);
          hull.add(pmqmr.times(-1));
        }
      }
      diag.plusEquals(pc[j]);
    }
    diag.timesEquals(1.0 / Math.sqrt(pc.length));
View Full Code Here

    for(int i = 1; i <= times; i++) {
      SVGPath path = new SVGPath();

      ArrayList<Vector> delta = new ArrayList<Vector>(chres.size());
      for(int p = 0; p < chres.size(); p++) {
        Vector prev = chres.get((p - 1 + chres.size()) % chres.size());
        Vector curr = chres.get(p);
        Vector next = chres.get((p + 1) % chres.size());
        Vector d1 = next.minus(curr).normalize();
        Vector d2 = curr.minus(prev).normalize();
        delta.add(d1.plus(d2));
        // delta.add(next.minus(prev));
      }

      for(int p = 0; p < chres.size(); p++) {
        Vector cur = cent.plus(chres.get(p));
        Vector nex = cent.plus(chres.get((p + 1) % chres.size()));
        Vector dcur = delta.get(p);
        Vector dnex = delta.get((p + 1) % chres.size());
        drawArc(path, cent, cur, nex, dcur, dnex, i);
      }
      path.close();

      Element ellipse = path.makeElement(svgp);
View Full Code Here

TOP

Related Classes of de.lmu.ifi.dbs.elki.math.linearalgebra.Vector

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.