use of com.revolsys.geometry.model.impl.PointDoubleXY in project com.revolsys.open by revolsys.
the class MiscellaneousTest2 method testDirectedEdgeToEdges.
public void testDirectedEdgeToEdges() {
final DirectedEdge d1 = new DirectedEdge(new Node(0, 0), new Node(10, 10), new PointDoubleXY(10, 10), true);
final DirectedEdge d2 = new DirectedEdge(new Node(20, 0), new Node(20, 10), new PointDoubleXY(20, 10), false);
final List edges = DirectedEdge.toEdges(Arrays.asList(d1, d2));
assertEquals(2, edges.size());
assertNull(edges.get(0));
assertNull(edges.get(1));
}
use of com.revolsys.geometry.model.impl.PointDoubleXY in project com.revolsys.open by revolsys.
the class LinearLocationTest method testSameSegmentMultiLineString.
public void testSameSegmentMultiLineString() throws Exception {
final Geometry line = this.geometryFactory.geometry("MULTILINESTRING ((0 0, 10 0, 20 0), (20 0, 30 0))");
final LocationIndexedLine indexedLine = new LocationIndexedLine(line);
final LinearLocation loc0 = indexedLine.indexOf(new PointDoubleXY(0, 0));
final LinearLocation loc0_5 = indexedLine.indexOf(new PointDoubleXY(5, 0));
final LinearLocation loc1 = indexedLine.indexOf(new PointDoubleXY(10, 0));
final LinearLocation loc2 = indexedLine.indexOf(new PointDoubleXY(20, 0));
final LinearLocation loc2B = new LinearLocation(1, 0, 0.0);
final LinearLocation loc2_5 = indexedLine.indexOf(new PointDoubleXY(25, 0));
final LinearLocation loc3 = indexedLine.indexOf(new PointDoubleXY(30, 0));
assertTrue(loc0.isOnSameSegment(loc0));
assertTrue(loc0.isOnSameSegment(loc0_5));
assertTrue(loc0.isOnSameSegment(loc1));
assertTrue(!loc0.isOnSameSegment(loc2));
assertTrue(!loc0.isOnSameSegment(loc2_5));
assertTrue(!loc0.isOnSameSegment(loc3));
assertTrue(loc0_5.isOnSameSegment(loc0));
assertTrue(loc0_5.isOnSameSegment(loc1));
assertTrue(!loc0_5.isOnSameSegment(loc2));
assertTrue(!loc0_5.isOnSameSegment(loc3));
assertTrue(!loc2.isOnSameSegment(loc0));
assertTrue(loc2.isOnSameSegment(loc1));
assertTrue(loc2.isOnSameSegment(loc2));
assertTrue(!loc2.isOnSameSegment(loc3));
assertTrue(loc2B.isOnSameSegment(loc3));
assertTrue(loc2_5.isOnSameSegment(loc3));
assertTrue(!loc3.isOnSameSegment(loc0));
assertTrue(!loc3.isOnSameSegment(loc2));
assertTrue(loc3.isOnSameSegment(loc2B));
assertTrue(loc3.isOnSameSegment(loc2_5));
assertTrue(loc3.isOnSameSegment(loc3));
}
use of com.revolsys.geometry.model.impl.PointDoubleXY in project com.revolsys.open by revolsys.
the class LinearLocationTest method testZeroLengthLineString.
public void testZeroLengthLineString() throws Exception {
final Geometry line = this.geometryFactory.geometry("LINESTRING (10 0, 10 0)");
final LocationIndexedLine indexedLine = new LocationIndexedLine(line);
final LinearLocation loc0 = indexedLine.indexOf(new PointDoubleXY(11, 0));
assertTrue(loc0.compareTo(new LinearLocation(1, 0.0)) == 0);
}
use of com.revolsys.geometry.model.impl.PointDoubleXY in project com.revolsys.open by revolsys.
the class AffineTransformationFactory method newFromControlVectors.
/**
* Creates an AffineTransformation defined by a pair of control vectors. A
* control vector consists of a source point and a destination point, which is
* the image of the source point under the desired transformation. The
* computed transformation is a combination of one or more of a uniform scale,
* a rotation, and a translation (i.e. there is no shear component and no
* reflection)
*
* @param src0
* @param src1
* @param dest0
* @param dest1
* @return the computed transformation
* @return null if the control vectors do not determine a well-defined transformation
*/
public static AffineTransformation newFromControlVectors(final Point src0, final Point src1, final Point dest0, final Point dest1) {
final Point rotPt = new PointDoubleXY(dest1.getX() - dest0.getX(), dest1.getY() - dest0.getY());
final double ang = Angle.angleBetweenOriented(src1, src0, rotPt);
final double srcDist = src1.distancePoint(src0);
final double destDist = dest1.distancePoint(dest0);
if (srcDist == 0.0) {
return null;
}
final double scale = destDist / srcDist;
final AffineTransformation trans = AffineTransformation.translationInstance(-src0.getX(), -src0.getY());
trans.rotate(ang);
trans.scale(scale, scale);
trans.translate(dest0.getX(), dest0.getY());
return trans;
}
use of com.revolsys.geometry.model.impl.PointDoubleXY in project com.revolsys.open by revolsys.
the class KochSnowflakeBuilder method getBoundary.
private Point[] getBoundary(final int level, final Point origin, final double width) {
double y = origin.getY();
// "arm" to centre it
if (level > 0) {
y += THIRD_HEIGHT * width;
}
final Point p0 = new PointDoubleXY(origin.getX(), y);
final Point p1 = new PointDoubleXY(origin.getX() + width / 2, y + width * HEIGHT_FACTOR);
final Point p2 = new PointDoubleXY(origin.getX() + width, y);
addSide(level, p0, p1);
addSide(level, p1, p2);
addSide(level, p2, p0);
this.coordList.closeRing();
return this.coordList.toPointArray();
}
Aggregations