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


Java AffineTransformation.translate方法代码示例

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


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

示例6: 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

示例7: rotate

import com.vividsolutions.jts.geom.util.AffineTransformation; //导入方法依赖的package包/类
/**
 * Rotates the geometry around the point (x,y)
 * @param g
 * @param angle
 * @param x
 * @param y
 * @return
 */
public static Geometry rotate(Geometry g, double angle, double x, double y)
{
  AffineTransformation trans = AffineTransformation.translationInstance(-x, -y);
  trans.rotate(angle);
  trans.translate(x, y);
  
  Geometry newG = (Geometry) g.clone();
  newG.apply(trans);
  return newG;
}
 
开发者ID:dr-jts,项目名称:jeql,代码行数:19,代码来源:GeomFunction.java

示例8: 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

示例9: normalizeLocation

import com.vividsolutions.jts.geom.util.AffineTransformation; //导入方法依赖的package包/类
@Override
public ILocation normalizeLocation(final ILocation point, final boolean nullIfOutside) {

	// TODO Subclass (or rewrite) this naive implementation to take care of
	// irregular
	// geometries.

	// TODO Take into account the fact that some topologies may consider
	// invalid locations.
	if (environment.getGeometry().covers(point)) { return point; }

	if (isTorus()) {
		final Point pt = GeometryUtils.GEOMETRY_FACTORY.createPoint(GeometryUtils.toCoordinate(point));

		for (int cnt = 0; cnt < 8; cnt++) {
			final AffineTransformation at = new AffineTransformation();
			at.translate(adjustedXVector[cnt], adjustedYVector[cnt]);
			final GamaPoint newPt = new GamaPoint(at.transform(pt).getCoordinate());
			if (environment.getGeometry().covers(newPt)) { return newPt; }
		}
	}
	// See if rounding errors of double do not interfere with the
	// computation.
	// In which case, the use of Maths.approxEquals(value1, value2,
	// tolerance) could help.

	// if ( envWidth == 0.0 ) {
	// xx = xx != envMinX ? nullIfOutside ? nil : envMinX : xx;
	// } else if ( xx < envMinX /* && xx > hostMinX - precision */) {
	// xx = /* !isTorus ? */nullIfOutside ? nil : envMinX /* : xx % envWidth
	// + envWidth */;
	// } else if ( xx >= envMaxX /*- precision*/) {
	// xx = /* !isTorus ? */nullIfOutside ? nil : envMaxX /* : xx % envWidth
	// */;
	// }
	// if ( xx == nil ) { return null; }
	// if ( envHeight == 0.0 ) {
	// yy = yy != envMinY ? nullIfOutside ? nil : envMinY : yy;
	// } else if ( yy < envMinY/* && yy > hostMinY - precision */) {
	// yy = /* !isTorus ? */nullIfOutside ? nil : envMinY /* : yy %
	// envHeight + envHeight */;
	// } else if ( yy >= envMaxY /*- precision*/) {
	// yy = /* !isTorus ? */nullIfOutside ? nil : envMaxY /* : yy %
	// envHeight */;
	// }
	// if ( yy == nil ) { return null; }
	// point.setLocation(xx, yy, point.getZ());

	return null;
}
 
开发者ID:gama-platform,项目名称:gama,代码行数:51,代码来源:AbstractTopology.java

示例10: 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.translate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。