use of com.revolsys.geometry.model.impl.PointDoubleXY in project com.revolsys.open by revolsys.
the class CoordinatesTest method testClone.
public void testClone() {
for (final Point point : //
Arrays.asList(//
new PointDoubleXY(100.0, 200.0), //
new PointDoubleXYZ(100.0, 200.0, 50.0), new PointDouble(100.0, 200.0, 50.0, 4.0))) {
final Point clone = point.newPoint();
assertEquals3d(point, clone);
}
}
use of com.revolsys.geometry.model.impl.PointDoubleXY in project com.revolsys.open by revolsys.
the class PolygonTest method testVertices.
@Test
public void testVertices() {
final List<Point> allCoordinates = new ArrayList<>();
allCoordinates.addAll(EXTERIOR_1);
allCoordinates.addAll(INTERIOR_2);
final Polygon polygon = WITH_HOLE;
int i = 0;
for (final Vertex vertex : polygon.vertices()) {
final Point point = allCoordinates.get(i);
Assert.assertEquals(point, vertex);
i++;
}
Assert.assertEquals(new PointDoubleXY(0.0, 0.0), polygon.getVertex(0, 0));
Assert.assertNull("VertexIndex out of range", polygon.getVertex(0, 6));
Assert.assertNull("VertexIndex out of range", polygon.getVertex(1, 6));
Assert.assertNull("RingIndex Negative", polygon.getVertex(-1, 0));
Assert.assertNull("RingIndex out of range", polygon.getVertex(2, 0));
}
use of com.revolsys.geometry.model.impl.PointDoubleXY in project com.revolsys.open by revolsys.
the class AbstractPointInRingTest method testRepeatedPts.
/**
* Tests that repeated points are handled correctly
* @throws Exception
*/
public void testRepeatedPts() throws Exception {
runPtInRing(Location.BOUNDARY, new PointDoubleXY(0.0, 0), repeatedPts);
runPtInRing(Location.BOUNDARY, new PointDoubleXY(0.0, 1), repeatedPts);
// at vertex
runPtInRing(Location.BOUNDARY, new PointDoubleXY(2.0, 5), repeatedPts);
runPtInRing(Location.BOUNDARY, new PointDoubleXY(8.0, 5), repeatedPts);
runPtInRing(Location.BOUNDARY, new PointDoubleXY(10.0, 5), repeatedPts);
runPtInRing(Location.INTERIOR, new PointDoubleXY(1.0, 5), repeatedPts);
runPtInRing(Location.INTERIOR, new PointDoubleXY(3.0, 5), repeatedPts);
}
use of com.revolsys.geometry.model.impl.PointDoubleXY in project com.revolsys.open by revolsys.
the class AffineTransformationTest method checkTransformation.
/**
* Checks that a transformation produces the expected result
* @param x the input pt x
* @param y the input pt y
* @param trans the transformation
* @param xp the expected output x
* @param yp the expected output y
*/
void checkTransformation(final double x, final double y, final AffineTransformation trans, final double xp, final double yp) {
final Point p = new PointDoubleXY(x, y);
final Point p2 = trans.transform(p);
assertEquals(xp, p2.getX(), .00005);
assertEquals(yp, p2.getY(), .00005);
// if the transformation is invertible, test the inverse
try {
final AffineTransformation invTrans = trans.getInverse();
final Point pInv = invTrans.transform(p2);
assertEquals(x, pInv.getX(), .00005);
assertEquals(y, pInv.getY(), .00005);
final double det = trans.getDeterminant();
final double detInv = invTrans.getDeterminant();
assertEquals(det, 1.0 / detInv, .00005);
} catch (final NoninvertibleTransformationException ex) {
}
}
use of com.revolsys.geometry.model.impl.PointDoubleXY in project com.revolsys.open by revolsys.
the class GeometryTestFactory method newCircle.
/**
* Creates a circle
* @param basex the centre x coord
* @param basey the centre y coord
* @param size the size of the envelope of the star
* @param nPts the number of points in the star
*/
public static Point[] newCircle(final double basex, final double basey, final double size, final int nPts) {
final Point[] pts = new Point[nPts + 1];
int iPt = 0;
final double len = size / 2.0;
for (int i = 0; i < nPts; i++) {
final double ang = i * (2 * Math.PI / nPts);
final double x = len * Math.cos(ang) + basex;
final double y = len * Math.sin(ang) + basey;
final Point pt = new PointDoubleXY(x, y);
pts[iPt++] = pt;
}
pts[iPt] = pts[0];
return pts;
}
Aggregations