Examples of AffineTransformation


Examples of com.vividsolutions.jts.geom.util.AffineTransformation

            at = new AffineTransform();
        }
        ROIGeometry roiGeometry = roiCache.get(at);
        if (roiGeometry == null) {
            Geometry rescaled;
            AffineTransformation geometryAT = new AffineTransformation(at.getScaleX(), at.getShearX(), at
                    .getTranslateX(), at.getShearY(), at.getScaleY(), at.getTranslateY());
            if (inset > 0) {
                double scale = Math.min(Math.abs(at.getScaleX()), Math.abs(at.getScaleY()));
                double rescaledInset = scale * inset;
                if (rescaledInset < 1) {
View Full Code Here

Examples of com.vividsolutions.jts.geom.util.AffineTransformation

        // wrap as a feature collection and return
    final SimpleFeatureType schema=CoverageUtilities.createFeatureType(gc2d,LineString.class);
        final SimpleFeatureBuilder builder = new SimpleFeatureBuilder(schema);
        int i=0;
        final ListFeatureCollection featureCollection= new ListFeatureCollection(schema);
        final AffineTransformation jtsTransformation=new AffineTransformation(
          mt2D.getScaleX(),
          mt2D.getShearX(),
          mt2D.getTranslateX(),
          mt2D.getShearY(),
          mt2D.getScaleY(),
View Full Code Here

Examples of com.vividsolutions.jts.geom.util.AffineTransformation

        // wrap as a feature collection and return
    final SimpleFeatureType featureType=CoverageUtilities.createFeatureType(coverage,Polygon.class);
        final SimpleFeatureBuilder builder = new SimpleFeatureBuilder(featureType);
        int i=0;
        final ListFeatureCollection featureCollection= new ListFeatureCollection(featureType);
        final AffineTransformation jtsTransformation=new AffineTransformation(
          mt2D.getScaleX(),
          mt2D.getShearX(),
          mt2D.getTranslateX(),
          mt2D.getShearY(),
          mt2D.getScaleY(),
View Full Code Here

Examples of com.vividsolutions.jts.geom.util.AffineTransformation

                //System.out.println(simplifiedGeometry.getEnvelopeInternal());
               
                // compensate for the jaitools range lookup poking the corner of the cells instead
                // of their center, this makes for odd results if the polygon is just slightly
                // misaligned with the coverage
                AffineTransformation at = new AffineTransformation();
               
                at.setToTranslation(-0.5, -0.5);
                simplifiedGeometry.apply(at);
               
                // build a shape using a fast point in polygon wrapper
                ROI roi = new ROIGeometry(simplifiedGeometry, false);
View Full Code Here

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

   * @return transformation matrix
   */
  public static AffineTransformation axisProjection(int dim, int ax1, int ax2) {
    // setup a projection to get the data into the interval -1:+1 in each
    // dimension with the intended-to-see dimensions first.
    AffineTransformation proj = AffineTransformation.reorderAxesTransformation(dim, new int[] { ax1, ax2 });
    // Assuming that the data was normalized on [0:1], center it:
    double[] trans = new double[dim];
    for(int i = 0; i < dim; i++) {
      trans[i] = -.5;
    }
    proj.addTranslation(new Vector(trans));
    // mirror on the y axis, since the SVG coordinate system is screen
    // coordinates (y = down) and not mathematical coordinates (y = up)
    proj.addAxisReflection(2);
    // scale it up
    proj.addScaling(SCALE);

    return proj;
  }
View Full Code Here

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

            it.tasks = tasks;
            master.subitems.add(it);
          }
        }
        if(dmax >= 3) {
          AffineTransformation p = AffineProjection.axisProjection(DatabaseUtil.dimensionality(rel), 1, 2);
          p.addRotation(0, 2, Math.PI / 180 * -10.);
          p.addRotation(1, 2, Math.PI / 180 * 15.);
          // Wanna try 4d? go ahead:
          // p.addRotation(0, 3, Math.PI / 180 * -20.);
          // p.addRotation(1, 3, Math.PI / 180 * 30.);
          Projection2D proj = new AffineProjection(scales.getScales(), p);
          PlotItem it = new PlotItem(sizeh + .1, 0, sizeh, sizeh, proj);
View Full Code Here

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

   * Test identity transform
   */
  @Test
  public void testIdentityTransform() {
    int testdim = 5;
    AffineTransformation t = new AffineTransformation(testdim);
    assertTrue(t.getDimensionality() == testdim);
    Matrix tm = t.getTransformation();
    assertEquals("initial transformation matrix should be unity", tm, Matrix.unitMatrix(testdim + 1));

    // test application to a vector
    double[] dv = new double[testdim];
    for(int i = 0; i < testdim; i++) {
      dv[i] = i * i + testdim;
    }
    Vector v1 = new Vector(dv.clone());
    Vector v2 = new Vector(dv.clone());

    Vector v3 = t.apply(v1);
    assertEquals("identity transformation wasn't identical", v2, v3);

    Vector v4 = t.applyInverse(v2);
    assertEquals("inverse of identity wasn't identity", v1, v4);
  }
View Full Code Here

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

   * Test adding translation vectors
   */
  @Test
  public void testTranslation() {
    int testdim = 5;
    AffineTransformation t = new AffineTransformation(testdim);
    assertTrue(t.getDimensionality() == testdim);
    Matrix tm = t.getTransformation();
    assertNotSame("getTransformation is expected to return a new copy", tm, t.getTransformation());
    assertEquals("initial transformation matrix should be unity", tm, Matrix.unitMatrix(testdim + 1));

    // translation vector
    double[] tv = new double[testdim];
    for(int i = 0; i < testdim; i++) {
      tv[i] = i + testdim;
    }
    t.addTranslation(new Vector(tv));

    Matrix tm2 = t.getTransformation();
    // Manually do the same changes to the matrix tm
    for(int i = 0; i < testdim; i++) {
      tm.set(i, testdim, i + testdim);
    }
    // Compare the results
    assertEquals("Translation wasn't added correctly to matrix.", tm, tm2);

    // test application to a vector
    double[] dv1 = new double[testdim];
    double[] dv2 = new double[testdim];
    for(int i = 0; i < testdim; i++) {
      dv1[i] = i * i + testdim;
      dv2[i] = i * i + i + 2 * testdim;
    }
    Vector v1 = new Vector(dv1);
    Vector v2t = new Vector(dv2);

    Vector v1t = t.apply(v1);
    assertEquals("Vector wasn't translated properly forward.", v2t, v1t);
    Vector v2b = t.applyInverse(v2t);
    assertEquals("Vector wasn't translated properly backwards.", v1, v2b);
    Vector v1b = t.applyInverse(v1t);
    assertEquals("Vector wasn't translated properly back and forward.", v1, v1b);

    // Translation
    Vector vd = v1.minus(v2b);
    Vector vtd = v1t.minus(v2t);
    assertEquals("Translation changed vector difference.", vd, vtd);

    // Translation shouldn't change relative vectors.
    assertEquals("Relative vectors weren't left unchanged by translation!", v1, t.applyRelative(v1));
    assertEquals("Relative vectors weren't left unchanged by translation!", v2t, t.applyRelative(v2t));
    assertEquals("Relative vectors weren't left unchanged by translation!", v1t, t.applyRelative(v1t));
    assertEquals("Relative vectors weren't left unchanged by translation!", v2b, t.applyRelative(v2b));
  }
View Full Code Here

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

    assert (axis1 < testdim);
    assert (axis2 < testdim);
    // don't change the angle; we'll be using that executing the rotation
    // three times will be identity (approximately)
    double angle = Math.toRadians(360 / 3);
    AffineTransformation t = new AffineTransformation(testdim);
    assertTrue(t.getDimensionality() == testdim);
    Matrix tm = t.getTransformation();
    assertNotSame("getTransformation is expected to return a new copy", tm, t.getTransformation());
    assertEquals("initial transformation matrix should be unity", tm, Matrix.unitMatrix(testdim + 1));

    // rotation matrix
    double[][] rm = new double[testdim][testdim];
    for(int i = 0; i < testdim; i++) {
      rm[i][i] = 1;
    }
    // add the rotation
    rm[axis1][axis1] = +Math.cos(angle);
    rm[axis1][axis2] = -Math.sin(angle);
    rm[axis2][axis1] = +Math.sin(angle);
    rm[axis2][axis2] = +Math.cos(angle);
    t.addMatrix(new Matrix(rm));
    Matrix tm2 = t.getTransformation();

    // We know that we didn't do any translations and tm is the unity matrix
    // so we can manually do the rotation on it, too.
    tm.set(axis1, axis1, +Math.cos(angle));
    tm.set(axis1, axis2, -Math.sin(angle));
    tm.set(axis2, axis1, +Math.sin(angle));
    tm.set(axis2, axis2, +Math.cos(angle));

    // Compare the results
    assertEquals("Rotation wasn't added correctly to matrix.", tm, tm2);

    // test application to a vector
    double[] dv = new double[testdim];
    for(int i = 0; i < testdim; i++) {
      dv[i] = i * i + testdim;
    }
    Vector v1 = new Vector(dv);
    Vector v2 = t.apply(v1);
    Vector v3 = t.applyInverse(v2);
    assertTrue("Forward-Backward didn't work correctly.", v1.minus(v3).euclideanLength() < 0.0001);
    Vector v4 = t.apply(t.apply(t.apply(v1)));
    assertTrue("Triple-Rotation by 120 degree didn't work", v1.minus(v4).euclideanLength() < 0.0001);

    // Rotation shouldn't disagree for relative vectors.
    // (they just are not affected by translation!)
    assertEquals("Relative vectors were affected differently by pure rotation!", v2, t.applyRelative(v1));

    // should do the same as built-in rotation!
    AffineTransformation t2 = new AffineTransformation(testdim);
    t2.addRotation(axis1, axis2, angle);
    Vector t2v2 = t2.apply(v1);
    assertTrue("Manual rotation and AffineTransformation.addRotation disagree.", v2.minus(t2v2).euclideanLength() < 0.0001);
  }
View Full Code Here

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

    // index in reference array
    int idx = 0;
    // with 0 arguments
    {
      AffineTransformation aff = AffineTransformation.reorderAxesTransformation(v.getDimensionality(), new int[] {});
      Vector n = aff.apply(v).minus(ps[idx]);
      assertEquals("Permutation " + idx + " doesn't match.", n.euclideanLength(), 0.0, 0.001);
      idx++;
    }
    // with one argument
    for(int d1 = 1; d1 <= 3; d1++) {
      AffineTransformation aff = AffineTransformation.reorderAxesTransformation(v.getDimensionality(), new int[] { d1 });
      Vector n = aff.apply(v).minus(ps[idx]);
      assertEquals("Permutation " + idx + " doesn't match.", n.euclideanLength(), 0.0, 0.001);
      idx++;
    }
    // with two arguments
    for(int d1 = 1; d1 <= 3; d1++) {
      for(int d2 = 1; d2 <= 3; d2++) {
        if(d1 == d2) {
          continue;
        }
        AffineTransformation aff = AffineTransformation.reorderAxesTransformation(v.getDimensionality(), new int[] { d1, d2 });
        Vector n = aff.apply(v).minus(ps[idx]);
        assertEquals("Permutation " + idx + " doesn't match.", n.euclideanLength(), 0.0, 0.001);
        idx++;
      }
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.