/** * Creates a copy of this vector * * @return a copy of this vector */ public Object clone() { return new Vector2D(this); }
/** * Creates a vector with the direction and magnitude * of the difference between the * <tt>to</tt> and <tt>from</tt> {@link Coordinate}s. * * @param from the origin Coordinate * @param to the destination Coordinate * @return a new vector */ public static Vector2D create(Coordinate from, Coordinate to) { return new Vector2D(from, to); }
/** * Creates a new vector with given X and Y components. * * @param x the x component * @param y the y component * @return a new vector */ public static Vector2D create(double x, double y) { return new Vector2D(x, y); }
/** * Creates a new vector from an existing one. * * @param v the vector to copy * @return a new vector */ public static Vector2D create(Vector2D v) { return new Vector2D(v); }
/** * Creates a vector from a {@link Coordinate}. * * @param coord the Coordinate to copy * @return a new vector */ public static Vector2D create(Coordinate coord) { return new Vector2D(coord); }
/** * * @param normal Plane normal * @param epsilon Epsilon value ex:1e-12 * @return The steepest slope of this plane in degree. */ public static double getSlopeInPercent(final Vector3D normal, final double epsilon) { Vector3D vector = getSteepestVector(normal, epsilon); if(Math.abs(vector.getZ()) < epsilon) { return 0; } else { return (Math.abs(vector.getZ()) / new Vector2D(vector.getX(), vector.getY()).length()) * 100; } }
/** * Compute the aspect in degree. The geometry must be a triangle. * @param geometry Polygon triangle * @return aspect in degree * @throws IllegalArgumentException ST_TriangleAspect accept only triangles */ public static Double computeAspect(Geometry geometry) throws IllegalArgumentException { if (geometry == null) { return null; } Vector3D vector = TriMarkers.getSteepestVector(TriMarkers.getNormalVector(TINFeatureFactory.createTriangle(geometry)), TINFeatureFactory.EPSILON); if (vector.length() < TINFeatureFactory.EPSILON) { return 0d; } else { Vector2D v = new Vector2D(vector.getX(), vector.getY()); return measureFromNorth(Math.toDegrees(v.angle())); } }
Vector2D vStart = new Vector2D(startCoordinate); double angleRad = elementaryAngle * i; Vector2D v = Vector2D.create(Math.cos(angleRad), Math.sin(angleRad));
private LineString voronoiSide(int idgeom, int side,GeometryFactory geometryFactory, Coordinate circumcenter) { boolean triangleCCW = isCCW(idgeom); // Create linestring to envelope LineSegment sideGeom = getTriangleSegment(idgeom, side); Vector2D direction = new Vector2D(sideGeom.p0, sideGeom.p1); direction = direction.normalize().rotate(triangleCCW ? - Math.PI / 2 : Math.PI / 2).multiply(envelope.maxExtent()); LineSegment voronoiLine = new LineSegment(circumcenter, new Coordinate(direction.getX() + circumcenter.x, direction.getY() + circumcenter.y)); Geometry lineString = voronoiLine.toGeometry(geometryFactory).intersection(geometryFactory.toGeometry(envelope)); if(lineString instanceof LineString && lineString.getLength() > epsilon) { return (LineString)lineString; } else { return null; } }