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


Java AffineTransformation.rotate方法代码示例

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


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

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

示例2: addObstacles

import com.vividsolutions.jts.geom.util.AffineTransformation; //导入方法依赖的package包/类
public void addObstacles(Geometry geom, Pose ... poses) {
	if (this.mapFilename == null) throw new Error("Please set a map file first!");
	BufferedImage img = null;
	try {
		img = ImageIO.read(new File(mapFilename)); 
		Graphics2D g2 = img.createGraphics();
		ShapeWriter writer = new ShapeWriter();
		g2.setPaint(Color.black);
		for (Pose pose : poses) {
			AffineTransformation at = new AffineTransformation();
			at.rotate(pose.getTheta());
			at.translate(pose.getX(), pose.getY());
			at.scale(1.0/mapResolution, -1.0/mapResolution);
			at.translate(0, img.getHeight());
			Geometry scaledGeom = at.transform(geom);
			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,代码行数:26,代码来源:ReedsSheppCarPlanner.java

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

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