use of com.revolsys.geometry.model.Point in project com.revolsys.open by revolsys.
the class PolygonEditor method insertVertex.
@Override
public GeometryEditor<?> insertVertex(final int[] vertexId, final Point point) {
if (vertexId == null || vertexId.length < 1) {
} else {
final int ringIndex = vertexId[0];
final LinearRingEditor editor = getEditor(ringIndex);
if (editor != null) {
final int[] childVertexId = Arrays.copyOfRange(vertexId, 1, vertexId.length);
editor.insertVertex(childVertexId, point);
}
}
return this;
}
use of com.revolsys.geometry.model.Point in project com.revolsys.open by revolsys.
the class PolygonEditor method appendVertex.
public PolygonalEditor appendVertex(final int ringIndex, final Point point) {
LinearRingEditor editor = getEditor(ringIndex);
if (editor == null) {
if (ringIndex == 0) {
editor = new LinearRingEditor(this);
this.editors.add(editor);
} else {
return this;
}
}
final int vertexCount = editor.getVertexCount();
if (vertexCount < 2) {
editor.appendVertex(point);
} else if (vertexCount == 2) {
editor.appendVertex(point);
final Point firstPoint = editor.getPoint(0);
editor.appendVertex(firstPoint);
} else {
editor.insertVertex(vertexCount - 1, point);
}
return this;
}
use of com.revolsys.geometry.model.Point in project com.revolsys.open by revolsys.
the class TriangleDouble method newTriangle.
public static Triangle newTriangle(final Point... points) {
if (points.length != 3) {
throw new IllegalArgumentException("A traingle must have exeactly 3 points not " + points.length);
}
final double[] coordinates = new double[9];
for (int i = 0; i < 3; i++) {
final Point point = points[i];
coordinates[i * 3] = point.getX();
coordinates[i * 3 + 1] = point.getY();
coordinates[i * 3 + 2] = point.getZ();
}
return new TriangleDouble(coordinates);
}
use of com.revolsys.geometry.model.Point in project com.revolsys.open by revolsys.
the class AffineTransformationFactory method newFromBaseLines.
/**
* Creates an AffineTransformation defined by a maping between two baselines.
* The computed transformation consists of:
* <ul>
* <li>a translation
* from the start point of the source baseline to the start point of the destination baseline,
* <li>a rotation through the angle between the baselines about the destination start point,
* <li>and a scaling equal to the ratio of the baseline lengths.
* </ul>
* If the source baseline has zero length, an identity transformation is returned.
*
* @param src0 the start point of the source baseline
* @param src1 the end point of the source baseline
* @param dest0 the start point of the destination baseline
* @param dest1 the end point of the destination baseline
* @return the computed transformation
*/
public static AffineTransformation newFromBaseLines(final Point src0, final Point src1, final Point dest0, final Point dest1) {
final Point rotPt = new PointDoubleXY(src0.getX() + dest1.getX() - dest0.getX(), src0.getY() + dest1.getY() - dest0.getY());
final double ang = Angle.angleBetweenOriented(src1, src0, rotPt);
final double srcDist = src1.distancePoint(src0);
final double destDist = dest1.distancePoint(dest0);
// return identity if transformation would be degenerate
if (srcDist == 0.0) {
return new AffineTransformation();
}
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.Point in project com.revolsys.open by revolsys.
the class FastNodingValidator method checkValid.
/**
* Checks for an intersection and throws
* a TopologyException if one is found.
*
* @throws TopologyException if an intersection is found
*/
public void checkValid() {
execute();
if (!this.isValid) {
final String errorMessage = getErrorMessage();
final Point interiorIntersection = this.segInt.getInteriorIntersection();
throw new TopologyException(errorMessage, interiorIntersection);
}
}
Aggregations