当前位置: 首页>>代码示例>>Java>>正文


Java AffineTransformation.transform方法代码示例

本文整理汇总了Java中com.vividsolutions.jts.geom.util.AffineTransformation.transform方法的典型用法代码示例。如果您正苦于以下问题:Java AffineTransformation.transform方法的具体用法?Java AffineTransformation.transform怎么用?Java AffineTransformation.transform使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.vividsolutions.jts.geom.util.AffineTransformation的用法示例。


在下文中一共展示了AffineTransformation.transform方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addObstacles

import com.vividsolutions.jts.geom.util.AffineTransformation; //导入方法依赖的package包/类
public void addObstacles(Geometry ... geom) {
	if (this.mapFilename == null) throw new Error("Please set a map file first!");
	BufferedImage img = null;
	try {
		img = ImageIO.read(new File(mapFilename)); 
		System.out.println("IMGTYPE: " + img.getType());
		Graphics2D g2 = img.createGraphics();
		ShapeWriter writer = new ShapeWriter();
		g2.setPaint(Color.black);
		for (Geometry g : geom) {
			AffineTransformation at = new AffineTransformation();
			at.scale(1.0/mapResolution, -1.0/mapResolution);
			at.translate(0, img.getHeight());
			Geometry scaledGeom = at.transform(g);
			Shape shape = writer.toShape(scaledGeom);
			System.out.println("Shape: " + shape.getBounds2D());
			g2.fill(shape);
		}
		File outputfile = new File(TEMP_MAP_DIR + File.separator + "tempMap" + (numObstacles++) + ".png");
		ImageIO.write(img, "png", outputfile);
		this.mapFilename = outputfile.getAbsolutePath();
	}
	catch (IOException e) { e.printStackTrace(); }		
}
 
开发者ID:FedericoPecora,项目名称:coordination_oru,代码行数:25,代码来源:ReedsSheppCarPlanner.java

示例2: makeObstacle

import com.vividsolutions.jts.geom.util.AffineTransformation; //导入方法依赖的package包/类
private Geometry makeObstacle(Pose p) {
	GeometryFactory gf = new GeometryFactory();
	Geometry geom = null;
	if (obstacleFootprint == null) {
		geom = gf.createPolygon(new Coordinate[] { new Coordinate(0.0,0.0), new Coordinate(0.0,OBSTACLE_SIZE), new Coordinate(OBSTACLE_SIZE,OBSTACLE_SIZE), new Coordinate(OBSTACLE_SIZE,0.0), new Coordinate(0.0,0.0) });
	}
	else {
		geom = gf.createPolygon(obstacleFootprint);
	}		
	AffineTransformation at = new AffineTransformation();
	at.rotate(p.getTheta());
	at.translate(p.getX(), p.getY());
	Geometry transGeom = at.transform(geom);
	Pose center = new Pose(p.getX(), p.getY(), p.getTheta());
	obstacles.add(transGeom);
	obstacleCenters.add(center);
	return transGeom;
}
 
开发者ID:FedericoPecora,项目名称:coordination_oru,代码行数:19,代码来源:PathEditor.java

示例3: createArrow

import com.vividsolutions.jts.geom.util.AffineTransformation; //导入方法依赖的package包/类
private Geometry createArrow(Pose pose1, Pose pose2) {		
	GeometryFactory gf = new GeometryFactory();
	double aux = 1.8;
	double distance = (1.6/targetArrowHeadWidth)*Math.sqrt(Math.pow((pose2.getX()-pose1.getX()),2)+Math.pow((pose2.getY()-pose1.getY()),2));
	double theta = Math.atan2(pose2.getY() - pose1.getY(), pose2.getX() - pose1.getX());
	Coordinate[] coords = new Coordinate[8];
	coords[0] = new Coordinate(0.0,-0.3);
	coords[1] = new Coordinate(distance-aux,-0.3);
	coords[2] = new Coordinate(distance-aux,-0.8);
	coords[3] = new Coordinate(distance,0.0);
	coords[4] = new Coordinate(distance-aux,0.8);
	coords[5] = new Coordinate(distance-aux,0.3);
	coords[6] = new Coordinate(0.0,0.3);
	coords[7] = new Coordinate(0.0,-0.3);
	Polygon arrow = gf.createPolygon(coords);
	AffineTransformation at = new AffineTransformation();
	at.scale(targetArrowHeadWidth/1.6, targetArrowHeadWidth/1.6);
	at.rotate(theta);
	at.translate(pose1.getX(), pose1.getY());
	Geometry ret = at.transform(arrow);
	return ret;
}
 
开发者ID:FedericoPecora,项目名称:meta-csp-framework,代码行数:23,代码来源:JTSDrawingPanel.java

示例4: getNearestIntersected

import com.vividsolutions.jts.geom.util.AffineTransformation; //导入方法依赖的package包/类
public AsteroidsSprite getNearestIntersected(Point loc, double rot, GameState world) {
  
  // Create worldTransform to transform to the local-space shape to world-space:
  AffineTransformation trans = new AffineTransformation();
  trans.rotate(-rot);
  trans.translate(loc.getX(), loc.getY());
  worldShape = new PolyWrapper((Polygon)trans.transform(localShape));
  
  // List of AsteroidsSprites that intersect with a circle described by
  // <loc, distanceToNearest>
  List<AsteroidsSprite> intersected = world.intersects(worldShape);
  
  // Nearest AsteroidsSprite:
  AsteroidsSprite nearest = AsteroidsSprite.nearest(loc, intersected);

  return nearest;
}
 
开发者ID:ndmacdon,项目名称:BraitenbergPilots,代码行数:18,代码来源:Components.java

示例5: testTransformationUtils2

import com.vividsolutions.jts.geom.util.AffineTransformation; //导入方法依赖的package包/类
public void testTransformationUtils2() throws Exception {
    Envelope env = new Envelope(100, 200, 1000, 5000);
    Rectangle rect = new Rectangle(0, 0, 100, 4000);

    AffineTransformation worldToPixel = TransformationUtils.getWorldToRectangle(env, rect);

    Coordinate srcPt = new Coordinate(150.0, 3000.0);
    Coordinate transformed = worldToPixel.transform(srcPt, new Coordinate());
    assertEquals(50, (int) transformed.x);
    assertEquals(2000, (int) transformed.y);

    srcPt = new Coordinate(100.0, 1000.0);
    transformed = worldToPixel.transform(srcPt, new Coordinate());
    assertEquals(0, (int) transformed.x);
    assertEquals(4000, (int) transformed.y);
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:17,代码来源:TestTransformationUtils.java

示例6: transformTest

import com.vividsolutions.jts.geom.util.AffineTransformation; //导入方法依赖的package包/类
public static void transformTest() {
    /*
     * 37.5116785 127.1021436
     * 
     * 37.5119898 127.1025482
     * 
     * 37.5134122 127.1025103
     */
    /*
     * 
     */
    Coordinate coord1 = new Coordinate(0.14195979899497488, 0.056451612903225756);
    Coordinate coord2 = new Coordinate(0.44597989949748745, 0.1088709677419355);
    Coordinate coord3 = new Coordinate(0.9849246231155779, 0.9905913978494624);
    Coordinate coord4 = new Coordinate(37.5116785, 127.1021436);
    Coordinate coord5 = new Coordinate(37.5119898, 127.1025482);
    Coordinate coord6 = new Coordinate(37.5134122, 127.1025103);

    Coordinate test = new Coordinate(0.9510050251256281, 0.728494623655914);

    Point p = JTSFactoryFinder.getGeometryFactory().createPoint(test);

    AffineTransformation affine = new AffineTransformationBuilder(coord1, coord2, coord3,
            coord4, coord5, coord6).getTransformation();
    Geometry geom = affine.transform(p);
    System.out.println(geom.toText());
}
 
开发者ID:STEMLab,项目名称:JInedit,代码行数:28,代码来源:test.java

示例7: makeFootprint

import com.vividsolutions.jts.geom.util.AffineTransformation; //导入方法依赖的package包/类
/**
 * Returns a {@link Geometry} representing the footprint of the robot in a given pose.
 * @param x The x coordinate of the pose used to create the footprint.
 * @param y The y coordinate of the pose used to create the footprint.
 * @param theta The orientation of the pose used to create the footprint.
 * @return A {@link Geometry} representing the footprint of the robot in a given pose.
 */
public Geometry makeFootprint(double x, double y, double theta) {
	AffineTransformation at = new AffineTransformation();
	at.rotate(theta);
	at.translate(x,y);
	Geometry rect = at.transform(footprint);
	return rect;
}
 
开发者ID:FedericoPecora,项目名称:meta-csp-framework,代码行数:15,代码来源:TrajectoryEnvelope.java

示例8: makeInnerFootprint

import com.vividsolutions.jts.geom.util.AffineTransformation; //导入方法依赖的package包/类
/**
 * Returns a {@link Geometry} representing the inner footprint of the robot in a given pose.
 * @param x The x coordinate of the pose used to create the inner footprint.
 * @param y The y coordinate of the pose used to create the inner footprint.
 * @param theta The orientation of the pose used to create the inner footprint.
 * @return A {@link Geometry} representing the footprint of the inner robot in a given pose.
 */
public Geometry makeInnerFootprint(double x, double y, double theta) {
	AffineTransformation at = new AffineTransformation();
	at.rotate(theta);
	at.translate(x,y);
	Geometry rect = at.transform(innerFootprint);
	return rect;
}
 
开发者ID:FedericoPecora,项目名称:meta-csp-framework,代码行数:15,代码来源:TrajectoryEnvelope.java

示例9: createTileGeom

import com.vividsolutions.jts.geom.util.AffineTransformation; //导入方法依赖的package包/类
/**
 * <p>Create geometry clipped and then converted to MVT 'extent' coordinates. Result
 * contains both clipped geometry (intersection) and transformed geometry for encoding to
 * MVT.</p>
 * <p>Allows specifying separate tile and clipping coordinates. {@code clipEnvelope} can be bigger
 * than {@code tileEnvelope} to have geometry exist outside the MVT tile extent.</p>
 *
 * @param geometryList   original 'source' geometry, passed through
 *                       {@link #flatFeatureList(Geometry)}
 * @param tileEnvelope   world coordinate bounds for tile, used for transforms
 * @param clipEnvelope   world coordinates to clip tile by
 * @param geomFactory    creates a geometry for the tile envelope
 * @param mvtLayerParams specifies vector tile properties
 * @param filter         geometry values that fail filter after transforms are removed
 * @return tile geometry result
 * @see TileGeomResult
 */
public static TileGeomResult createTileGeom(List<Geometry> geometryList,
                                            Envelope tileEnvelope,
                                            Envelope clipEnvelope,
                                            GeometryFactory geomFactory,
                                            MvtLayerParams mvtLayerParams,
                                            IGeometryFilter filter) {

  final Geometry tileClipGeom = geomFactory.toGeometry(clipEnvelope);

  final AffineTransformation t = new AffineTransformation();
  final double xDiff = tileEnvelope.getWidth();
  final double yDiff = tileEnvelope.getHeight();

  final double xOffset = -tileEnvelope.getMinX();
  final double yOffset = -tileEnvelope.getMinY();

  // Transform Setup: Shift to 0 as minimum value
  t.translate(xOffset, yOffset);

  // Transform Setup: Scale X and Y to tile extent values, flip Y values
  t.scale(1d / (xDiff / (double) mvtLayerParams.extent),
      -1d / (yDiff / (double) mvtLayerParams.extent));

  // Transform Setup: Bump Y values to positive quadrant
  t.translate(0d, (double) mvtLayerParams.extent);


  // The area contained in BOTH the 'original geometry', g, AND the 'clip envelope geometry' is
  // the 'tile geometry'
  final List<Geometry> intersectedGeoms = flatIntersection(tileClipGeom, geometryList);
  final List<Geometry> transformedGeoms = new ArrayList<>(intersectedGeoms.size());

  // Transform intersected geometry
  Geometry nextTransformGeom;
  Object nextUserData;
  for (Geometry nextInterGeom : intersectedGeoms) {
    nextUserData = nextInterGeom.getUserData();

    nextTransformGeom = t.transform(nextInterGeom);

    // Floating --> Integer, still contained within doubles
    nextTransformGeom.apply(RoundingFilter.INSTANCE);

    // TODO: Refactor line simplification
    // Can't use 0d, specify value < .5d
    nextTransformGeom = TopologyPreservingSimplifier.simplify(nextTransformGeom, .1d);

    nextTransformGeom.setUserData(nextUserData);

    // Apply filter on transformed geometry
    if (filter.accept(nextTransformGeom)) {
      transformedGeoms.add(nextTransformGeom);
    }
  }

  return new TileGeomResult(intersectedGeoms, transformedGeoms);
}
 
开发者ID:OrdnanceSurvey,项目名称:vt-support,代码行数:75,代码来源:JtsAdapter.java

示例10: getSectionsFromCoordinates

import com.vividsolutions.jts.geom.util.AffineTransformation; //导入方法依赖的package包/类
/**
 * Extracts traversal sections of a given with from the supplied {@link Coordinate}s.
 * 
 * @param coordinates the list of coordinates.
 * @param width the total with of the sections.
 * @return the list of {@link LineString sections}. 
 */
public static List<LineString> getSectionsFromCoordinates( List<Coordinate> coordinates, double width ) {

    if (coordinates.size() < 3) {
        throw new IllegalArgumentException("This method works only on lines with at least 3 coordinates.");
    }
    double halfWidth = width / 2.0;
    List<LineString> linesList = new ArrayList<LineString>();
    // first section
    Coordinate centerCoordinate = coordinates.get(0);
    LineSegment l1 = new LineSegment(centerCoordinate, coordinates.get(1));
    Coordinate leftCoordinate = l1.pointAlongOffset(0.0, halfWidth);
    Coordinate rightCoordinate = l1.pointAlongOffset(0.0, -halfWidth);
    LineString lineString = geomFactory.createLineString(new Coordinate[]{leftCoordinate, centerCoordinate, rightCoordinate});
    linesList.add(lineString);

    for( int i = 1; i < coordinates.size() - 1; i++ ) {
        Coordinate previous = coordinates.get(i - 1);
        Coordinate current = coordinates.get(i);
        Coordinate after = coordinates.get(i + 1);

        double firstAngle = azimuth(current, previous);
        double secondAngle = azimuth(current, after);

        double a1 = min(firstAngle, secondAngle);
        double a2 = max(firstAngle, secondAngle);

        double centerAngle = a1 + (a2 - a1) / 2.0;

        AffineTransformation rotationInstance = AffineTransformation.rotationInstance(-toRadians(centerAngle), current.x,
                current.y);

        LineString vertical = geomFactory.createLineString(new Coordinate[]{new Coordinate(current.x, current.y + halfWidth),
                current, new Coordinate(current.x, current.y - halfWidth)});
        Geometry transformed = rotationInstance.transform(vertical);
        linesList.add((LineString) transformed);
    }

    // last section
    centerCoordinate = coordinates.get(coordinates.size() - 1);
    LineSegment l2 = new LineSegment(centerCoordinate, coordinates.get(coordinates.size() - 2));
    leftCoordinate = l2.pointAlongOffset(0.0, halfWidth);
    rightCoordinate = l2.pointAlongOffset(0.0, -halfWidth);
    lineString = geomFactory.createLineString(new Coordinate[]{leftCoordinate, centerCoordinate, rightCoordinate});
    linesList.add(lineString);

    return linesList;
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:55,代码来源:GeometryUtilities.java

示例11: getFootprint

import com.vividsolutions.jts.geom.util.AffineTransformation; //导入方法依赖的package包/类
/**
 * Returns a {@link Geometry} representing the footprint of a robot in a given pose.
 * @param fp A polygon representing the footprint of the robot centered in (0,0)
 * and appropriately oriented (can be obtained from a {@link TrajectoryEnvelope} instance
 * via method {@link TrajectoryEnvelope#getFootprint()}).
 * @param x The x coordinate of the pose used to create the footprint.
 * @param y The y coordinate of the pose used to create the footprint.
 * @param theta The orientation of the pose used to create the footprint.
 * @return A {@link Geometry} representing the footprint of the robot in a given pose.
 */
public static Geometry getFootprint(Polygon fp, double x, double y, double theta) {
	AffineTransformation at = new AffineTransformation();
	at.rotate(theta);
	at.translate(x,y);
	Geometry rect = at.transform(fp);
	return rect;
}
 
开发者ID:FedericoPecora,项目名称:meta-csp-framework,代码行数:18,代码来源:TrajectoryEnvelope.java


注:本文中的com.vividsolutions.jts.geom.util.AffineTransformation.transform方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。