List of usage examples for org.apache.commons.math3.geometry.euclidean.twod PolygonsSet PolygonsSet
public PolygonsSet(final double hyperplaneThickness, final Vector2D... vertices)
From source file:org.micromanager.plugins.magellan.surfacesandregions.MultiPosRegion.java
private Region<Euclidean2D> getStagePositionRegion(XYStagePosition pos) { Region<Euclidean2D> square; Point2D.Double[] corners = pos.getDisplayedTileCorners(); square = new PolygonsSet(0.0001, new Vector2D[] { new Vector2D(corners[0].x, corners[0].y), new Vector2D(corners[1].x, corners[1].y), new Vector2D(corners[2].x, corners[2].y), new Vector2D(corners[3].x, corners[3].y) }); return square.checkPoint(new Vector2D(pos.getCenter().x, pos.getCenter().y)) == Region.Location.OUTSIDE ? regionFacotry_.getComplement(square) : square;/*from ww w . j a va 2 s . c o m*/ }
From source file:org.micromanager.plugins.magellan.surfacesandregions.SurfaceInterpolator.java
/** * Create a 2D square region corresponding to the the stage position + any extra padding * @param pos//w w w . j a v a2s .c om * @return */ private Region<Euclidean2D> getStagePositionRegion(XYStagePosition pos) { Region<Euclidean2D> square; Point2D.Double[] corners = pos.getDisplayedTileCorners(); if (xyPadding_um_ == 0) { square = new PolygonsSet(0.0001, new Vector2D[] { new Vector2D(corners[0].x, corners[0].y), new Vector2D(corners[1].x, corners[1].y), new Vector2D(corners[2].x, corners[2].y), new Vector2D(corners[3].x, corners[3].y) }); } else { //expand to bigger square to acount for padding //make two lines that criss cross the smaller square double diagonalLength = new Vector2D(corners[0].x, corners[0].y) .distance(new Vector2D(corners[2].x, corners[2].y)); Vector2D center = new Vector2D(pos.getCenter().x, pos.getCenter().y); square = new PolygonsSet(0.0001, new Vector2D[] { center.add(xyPadding_um_ + 0.5 * diagonalLength, new Vector2D(corners[0].x - corners[2].x, corners[0].y - corners[2].y) .normalize()), center.add(xyPadding_um_ + 0.5 * diagonalLength, new Vector2D(corners[1].x - corners[3].x, corners[1].y - corners[3].y) .normalize()), center.add(xyPadding_um_ + 0.5 * diagonalLength, new Vector2D(corners[2].x - corners[0].x, corners[2].y - corners[0].y) .normalize()), center.add(xyPadding_um_ + 0.5 * diagonalLength, new Vector2D(corners[3].x - corners[1].x, corners[3].y - corners[1].y) .normalize()) }); } return square.checkPoint(new Vector2D(pos.getCenter().x, pos.getCenter().y)) == Region.Location.OUTSIDE ? regionFacotry_.getComplement(square) : square; }