public static Coordinate normalize(Coordinate v) { double len = length(v); return new Coordinate(v.x / len, v.y / len, v.z / len); } /**
/** * Computes the oriented distance from a point to the plane. * The distance is: * <ul> * <li><b>positive</b> if the point lies above the plane (relative to the plane normal) * <li><b>zero</b> if the point is on the plane * <li><b>negative</b> if the point lies below the plane (relative to the plane normal) * </ul> * * @param p the point to compute the distance for * @return the oriented distance to the plane */ public double orientedDistance(Coordinate p) { Vector3D pb = new Vector3D(p, basePt); double pbdDotNormal = pb.dot(normal); if (Double.isNaN(pbdDotNormal)) throw new IllegalArgumentException("3D Coordinate has NaN ordinate"); double d = pbdDotNormal / normal.length(); return d; }
public static Coordinate normalize(Coordinate v) { double len = length(v); return new Coordinate(v.x / len, v.y / len, v.z / len); } /**
/** * Computes the oriented distance from a point to the plane. * The distance is: * <ul> * <li><b>positive</b> if the point lies above the plane (relative to the plane normal) * <li><b>zero</b> if the point is on the plane * <li><b>negative</b> if the point lies below the plane (relative to the plane normal) * </ul> * * @param p the point to compute the distance for * @return the oriented distance to the plane */ public double orientedDistance(Coordinate p) { Vector3D pb = new Vector3D(p, basePt); double pbdDotNormal = pb.dot(normal); if (Double.isNaN(pbdDotNormal)) throw new IllegalArgumentException("3D Coordinate has NaN ordinate"); double d = pbdDotNormal / normal.length(); return d; }
/** * 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())); } }
/** * 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())); } }