Class Plane

java.lang.Object
org.apache.lucene.spatial3d.geom.Vector
org.apache.lucene.spatial3d.geom.Plane
Direct Known Subclasses:
SidedPlane

public class Plane extends Vector
We know about three kinds of planes. First kind: general plain through two points and origin Second kind: horizontal plane at specified height. Third kind: vertical plane with specified x and y value, through origin.
WARNING: This API is experimental and might change in incompatible ways in the next release.
  • Field Details

    • NO_POINTS

      public static final GeoPoint[] NO_POINTS
      An array with no points in it
    • NO_BOUNDS

      public static final Membership[] NO_BOUNDS
      An array with no bounds in it
    • normalYPlane

      public static final Plane normalYPlane
      A vertical plane normal to the Y axis
    • normalXPlane

      public static final Plane normalXPlane
      A vertical plane normal to the X axis
    • normalZPlane

      public static final Plane normalZPlane
      A vertical plane normal to the Z axis
    • D

      public final double D
      Ax + By + Cz + D = 0
  • Constructor Details

    • Plane

      public Plane(double A, double B, double C, double D)
      Construct a plane with all four coefficients defined.
      Parameters:
      A - is A
      B - is B
      C - is C
      D - is D
    • Plane

      public Plane(Vector A, double BX, double BY, double BZ)
      Construct a plane through two points and origin.
      Parameters:
      A - is the first point (origin based).
      BX - is the second point X (origin based).
      BY - is the second point Y (origin based).
      BZ - is the second point Z (origin based).
    • Plane

      public Plane(Vector A, Vector B)
      Construct a plane through two points and origin.
      Parameters:
      A - is the first point (origin based).
      B - is the second point (origin based).
    • Plane

      public Plane(PlanetModel planetModel, double sinLat)
      Construct a horizontal plane at a specified Z.
      Parameters:
      planetModel - is the planet model.
      sinLat - is the sin(latitude).
    • Plane

      public Plane(double x, double y)
      Construct a vertical plane through a specified x, y and origin.
      Parameters:
      x - is the specified x value.
      y - is the specified y value.
    • Plane

      public Plane(Vector v, double D)
      Construct a plane with a specific vector, and D offset from origin.
      Parameters:
      v - is the normal vector.
      D - is the D offset from the origin.
    • Plane

      public Plane(Plane basePlane, boolean above)
      Construct a plane that is parallel to the one provided, but which is just barely numerically distinguishable from it, in the direction desired.
      Parameters:
      basePlane - is the starting plane.
      above - is set to true if the desired plane is in the positive direction from the base plane, or false in the negative direction.
  • Method Details

    • constructNormalizedZPlane

      public static Plane constructNormalizedZPlane(Vector... planePoints)
      Construct the most accurate normalized plane through an x-y point and including the Z axis. If none of the points can determine the plane, return null.
      Parameters:
      planePoints - is a set of points to choose from. The best one for constructing the most precise plane is picked.
      Returns:
      the plane
    • constructNormalizedYPlane

      public static Plane constructNormalizedYPlane(Vector... planePoints)
      Construct the most accurate normalized plane through an x-z point and including the Y axis. If none of the points can determine the plane, return null.
      Parameters:
      planePoints - is a set of points to choose from. The best one for constructing the most precise plane is picked.
      Returns:
      the plane
    • constructNormalizedXPlane

      public static Plane constructNormalizedXPlane(Vector... planePoints)
      Construct the most accurate normalized plane through an y-z point and including the X axis. If none of the points can determine the plane, return null.
      Parameters:
      planePoints - is a set of points to choose from. The best one for constructing the most precise plane is picked.
      Returns:
      the plane
    • constructNormalizedZPlane

      public static Plane constructNormalizedZPlane(double x, double y)
      Construct a normalized plane through an x-y point and including the Z axis. If the x-y point is at (0,0), return null.
      Parameters:
      x - is the x value.
      y - is the y value.
      Returns:
      a plane passing through the Z axis and (x,y,0).
    • constructNormalizedYPlane

      public static Plane constructNormalizedYPlane(double x, double z, double DValue)
      Construct a normalized plane through an x-z point and parallel to the Y axis. If the x-z point is at (0,0), return null.
      Parameters:
      x - is the x value.
      z - is the z value.
      DValue - is the offset from the origin for the plane.
      Returns:
      a plane parallel to the Y axis and perpendicular to the x and z values given.
    • constructNormalizedXPlane

      public static Plane constructNormalizedXPlane(double y, double z, double DValue)
      Construct a normalized plane through a y-z point and parallel to the X axis. If the y-z point is at (0,0), return null.
      Parameters:
      y - is the y value.
      z - is the z value.
      DValue - is the offset from the origin for the plane.
      Returns:
      a plane parallel to the X axis and perpendicular to the y and z values given.
    • evaluate

      public double evaluate(Vector v)
      Evaluate the plane equation for a given point, as represented by a vector.
      Parameters:
      v - is the vector.
      Returns:
      the result of the evaluation.
    • evaluate

      public double evaluate(double x, double y, double z)
      Evaluate the plane equation for a given point, as represented by a vector.
      Parameters:
      x - is the x value.
      y - is the y value.
      z - is the z value.
      Returns:
      the result of the evaluation.
    • evaluateIsZero

      public boolean evaluateIsZero(Vector v)
      Evaluate the plane equation for a given point, as represented by a vector.
      Parameters:
      v - is the vector.
      Returns:
      true if the result is on the plane.
    • evaluateIsZero

      public boolean evaluateIsZero(double x, double y, double z)
      Evaluate the plane equation for a given point, as represented by a vector.
      Parameters:
      x - is the x value.
      y - is the y value.
      z - is the z value.
      Returns:
      true if the result is on the plane.
    • normalize

      public Plane normalize()
      Build a normalized plane, so that the vector is normalized.
      Overrides:
      normalize in class Vector
      Returns:
      the normalized plane object, or null if the plane is indeterminate.
    • arcDistance

      public double arcDistance(PlanetModel planetModel, GeoPoint v, Membership... bounds)
      Compute arc distance from plane to a vector expressed with a GeoPoint.
      See Also:
    • arcDistance

      public double arcDistance(PlanetModel planetModel, double x, double y, double z, Membership... bounds)
      Compute arc distance from plane to a vector.
      Parameters:
      planetModel - is the planet model.
      x - is the x vector value.
      y - is the y vector value.
      z - is the z vector value.
      bounds - are the bounds which constrain the intersection point.
      Returns:
      the arc distance.
    • normalDistance

      public double normalDistance(Vector v, Membership... bounds)
      Compute normal distance from plane to a vector.
      Parameters:
      v - is the vector.
      bounds - are the bounds which constrain the intersection point.
      Returns:
      the normal distance.
    • normalDistance

      public double normalDistance(double x, double y, double z, Membership... bounds)
      Compute normal distance from plane to a vector.
      Parameters:
      x - is the vector x.
      y - is the vector y.
      z - is the vector z.
      bounds - are the bounds which constrain the intersection point.
      Returns:
      the normal distance.
    • normalDistanceSquared

      public double normalDistanceSquared(Vector v, Membership... bounds)
      Compute normal distance squared from plane to a vector.
      Parameters:
      v - is the vector.
      bounds - are the bounds which constrain the intersection point.
      Returns:
      the normal distance squared.
    • normalDistanceSquared

      public double normalDistanceSquared(double x, double y, double z, Membership... bounds)
      Compute normal distance squared from plane to a vector.
      Parameters:
      x - is the vector x.
      y - is the vector y.
      z - is the vector z.
      bounds - are the bounds which constrain the intersection point.
      Returns:
      the normal distance squared.
    • linearDistance

      public double linearDistance(PlanetModel planetModel, GeoPoint v, Membership... bounds)
      Compute linear distance from plane to a vector. This is defined as the distance from the given point to the nearest intersection of this plane with the planet surface.
      Parameters:
      planetModel - is the planet model.
      v - is the point.
      bounds - are the bounds which constrain the intersection point.
      Returns:
      the linear distance.
    • linearDistance

      public double linearDistance(PlanetModel planetModel, double x, double y, double z, Membership... bounds)
      Compute linear distance from plane to a vector. This is defined as the distance from the given point to the nearest intersection of this plane with the planet surface.
      Parameters:
      planetModel - is the planet model.
      x - is the vector x.
      y - is the vector y.
      z - is the vector z.
      bounds - are the bounds which constrain the intersection point.
      Returns:
      the linear distance.
    • linearDistanceSquared

      public double linearDistanceSquared(PlanetModel planetModel, GeoPoint v, Membership... bounds)
      Compute linear distance squared from plane to a vector. This is defined as the distance from the given point to the nearest intersection of this plane with the planet surface.
      Parameters:
      planetModel - is the planet model.
      v - is the point.
      bounds - are the bounds which constrain the intersection point.
      Returns:
      the linear distance squared.
    • linearDistanceSquared

      public double linearDistanceSquared(PlanetModel planetModel, double x, double y, double z, Membership... bounds)
      Compute linear distance squared from plane to a vector. This is defined as the distance from the given point to the nearest intersection of this plane with the planet surface.
      Parameters:
      planetModel - is the planet model.
      x - is the vector x.
      y - is the vector y.
      z - is the vector z.
      bounds - are the bounds which constrain the intersection point.
      Returns:
      the linear distance squared.
    • interpolate

      public GeoPoint[] interpolate(PlanetModel planetModel, GeoPoint start, GeoPoint end, double[] proportions)
      Find points on the boundary of the intersection of a plane and the unit sphere, given a starting point, and ending point, and a list of proportions of the arc (e.g. 0.25, 0.5, 0.75). The angle between the starting point and ending point is assumed to be less than pi.
      Parameters:
      planetModel - is the planet model.
      start - is the start point.
      end - is the end point.
      proportions - is an array of fractional proportions measured between start and end.
      Returns:
      an array of points corresponding to the proportions passed in.
    • modify

      protected static Vector modify(GeoPoint start, double transX, double transY, double transZ, double sinRA, double cosRA, double sinHA, double cosHA)
      Modify a point to produce a vector in translated/rotated space.
      Parameters:
      start - is the start point.
      transX - is the translation x value.
      transY - is the translation y value.
      transZ - is the translation z value.
      sinRA - is the sine of the ascension angle.
      cosRA - is the cosine of the ascension angle.
      sinHA - is the sine of the height angle.
      cosHA - is the cosine of the height angle.
      Returns:
      the modified point.
    • reverseModify

      protected static GeoPoint reverseModify(PlanetModel planetModel, Vector point, double transX, double transY, double transZ, double sinRA, double cosRA, double sinHA, double cosHA)
      Reverse modify a point to produce a GeoPoint in normal space.
      Parameters:
      planetModel - is the planet model.
      point - is the translated point.
      transX - is the translation x value.
      transY - is the translation y value.
      transZ - is the translation z value.
      sinRA - is the sine of the ascension angle.
      cosRA - is the cosine of the ascension angle.
      sinHA - is the sine of the height angle.
      cosHA - is the cosine of the height angle.
      Returns:
      the original point.
    • findIntersections

      public GeoPoint[] findIntersections(PlanetModel planetModel, Plane q, Membership... bounds)
      Find the intersection points between two planes, given a set of bounds.
      Parameters:
      planetModel - is the planet model.
      q - is the plane to intersect with.
      bounds - are the bounds to consider to determine legal intersection points.
      Returns:
      the set of legal intersection points, or null if the planes are numerically identical.
    • findCrossings

      public GeoPoint[] findCrossings(PlanetModel planetModel, Plane q, Membership... bounds)
      Find the points between two planes, where one plane crosses the other, given a set of bounds. Crossing is not just intersection; the planes cannot touch at just one point on the ellipsoid, but must cross at two.
      Parameters:
      planetModel - is the planet model.
      q - is the plane to intersect with.
      bounds - are the bounds to consider to determine legal intersection points.
      Returns:
      the set of legal crossing points, or null if the planes are numerically identical.
    • arePointsCoplanar

      public static boolean arePointsCoplanar(GeoPoint A, GeoPoint B, GeoPoint C)
      Checks if three points are coplanar in any of the three planes they can describe. The planes are all assumed to go through the origin.
      Parameters:
      A - The first point.
      B - The second point.
      C - The third point
      Returns:
      true if provided points are coplanar in any of the three planes they can describe.
    • findIntersections

      protected GeoPoint[] findIntersections(PlanetModel planetModel, Plane q, Membership[] bounds, Membership[] moreBounds)
      Find the intersection points between two planes, given a set of bounds.
      Parameters:
      planetModel - is the planet model to use in finding points.
      q - is the plane to intersect with.
      bounds - is the set of bounds.
      moreBounds - is another set of bounds.
      Returns:
      the intersection point(s) on the unit sphere, if there are any.
    • findCrossings

      protected GeoPoint[] findCrossings(PlanetModel planetModel, Plane q, Membership[] bounds, Membership[] moreBounds)
      Find the points between two planes, where one plane crosses the other, given a set of bounds. Crossing is not just intersection; the planes cannot touch at just one point on the ellipsoid, but must cross at two.
      Parameters:
      planetModel - is the planet model to use in finding points.
      q - is the plane to intersect with.
      bounds - is the set of bounds.
      moreBounds - is another set of bounds.
      Returns:
      the intersection point(s) on the ellipsoid, if there are any.
    • findIntersectionBounds

      protected void findIntersectionBounds(PlanetModel planetModel, Bounds boundsInfo, Plane q, Membership... bounds)
      Record intersection points for planes with error bounds. This method calls the Bounds object with every intersection point it can find that matches the criteria. Each plane is considered to have two sides, one that is D + MINIMUM_RESOLUTION, and one that is D - MINIMUM_RESOLUTION. Both are examined and intersection points determined.
    • recordBounds

      public void recordBounds(PlanetModel planetModel, XYZBounds boundsInfo, Plane p, Membership... bounds)
      Accumulate (x,y,z) bounds information for this plane, intersected with another and the world. Updates min/max information using intersection points found. These include the error envelope for the planes (D +/- MINIMUM_RESOLUTION).
      Parameters:
      planetModel - is the planet model to use in determining bounds.
      boundsInfo - is the xyz info to update with additional bounding information.
      p - is the other plane.
      bounds - are the surfaces delineating what's inside the shape.
    • recordBounds

      public void recordBounds(PlanetModel planetModel, XYZBounds boundsInfo, Membership... bounds)
      Accumulate (x,y,z) bounds information for this plane, intersected with the unit sphere. Updates min/max information, using max/min points found within the specified bounds.
      Parameters:
      planetModel - is the planet model to use in determining bounds.
      boundsInfo - is the xyz info to update with additional bounding information.
      bounds - are the surfaces delineating what's inside the shape.
    • recordBounds

      public void recordBounds(PlanetModel planetModel, LatLonBounds boundsInfo, Plane p, Membership... bounds)
      Accumulate bounds information for this plane, intersected with another plane and the world. Updates both latitude and longitude information, using max/min points found within the specified bounds. Also takes into account the error envelope for all planes being intersected.
      Parameters:
      planetModel - is the planet model to use in determining bounds.
      boundsInfo - is the lat/lon info to update with additional bounding information.
      p - is the other plane.
      bounds - are the surfaces delineating what's inside the shape.
    • recordBounds

      public void recordBounds(PlanetModel planetModel, LatLonBounds boundsInfo, Membership... bounds)
      Accumulate bounds information for this plane, intersected with the unit sphere. Updates both latitude and longitude information, using max/min points found within the specified bounds.
      Parameters:
      planetModel - is the planet model to use in determining bounds.
      boundsInfo - is the lat/lon info to update with additional bounding information.
      bounds - are the surfaces delineating what's inside the shape.
    • intersects

      public boolean intersects(PlanetModel planetModel, Plane q, GeoPoint[] notablePoints, GeoPoint[] moreNotablePoints, Membership[] bounds, Membership... moreBounds)
      Determine whether the plane intersects another plane within the bounds provided.
      Parameters:
      planetModel - is the planet model to use in determining intersection.
      q - is the other plane.
      notablePoints - are points to look at to disambiguate cases when the two planes are identical.
      moreNotablePoints - are additional points to look at to disambiguate cases when the two planes are identical.
      bounds - is one part of the bounds.
      moreBounds - are more bounds.
      Returns:
      true if there's an intersection.
    • crosses

      public boolean crosses(PlanetModel planetModel, Plane q, GeoPoint[] notablePoints, GeoPoint[] moreNotablePoints, Membership[] bounds, Membership... moreBounds)
      Determine whether the plane crosses another plane within the bounds provided. Crossing is defined as intersecting with the geo surface at two points.
      Parameters:
      planetModel - is the planet model to use in determining intersection.
      q - is the other plane.
      notablePoints - are points to look at to disambiguate cases when the two planes are identical.
      moreNotablePoints - are additional points to look at to disambiguate cases when the two planes are identical.
      bounds - is one part of the bounds.
      moreBounds - are more bounds.
      Returns:
      true if there's a crossing.
    • isFunctionallyIdentical

      public boolean isFunctionallyIdentical(Plane p)
      Returns true if this plane and the other plane are functionally identical within the margin of error. Functionally identical means that the planes are so close to parallel that many aspects of planar math, like intersections, no longer have answers to within the required precision.
      Parameters:
      p - is the plane to compare against.
      Returns:
      true if the planes are functionally identical.
    • isNumericallyIdentical

      public boolean isNumericallyIdentical(Plane p)
      Returns true if this plane and the other plane are identical within the margin of error.
      Parameters:
      p - is the plane to compare against.
      Returns:
      true if the planes are numerically identical.
    • findArcDistancePoints

      public GeoPoint[] findArcDistancePoints(PlanetModel planetModel, double arcDistanceValue, GeoPoint startPoint, Membership... bounds)
      Locate a point that is within the specified bounds and on the specified plane, that has an arcDistance as specified from the startPoint.
      Parameters:
      planetModel - is the planet model.
      arcDistanceValue - is the arc distance.
      startPoint - is the starting point.
      bounds - are the bounds.
      Returns:
      zero, one, or two points.
    • getSampleIntersectionPoint

      public GeoPoint getSampleIntersectionPoint(PlanetModel planetModel, Plane q)
      Find a sample point on the intersection between two planes and the world.
      Parameters:
      planetModel - is the planet model.
      q - is the second plane to consider.
      Returns:
      a sample point that is on the intersection between the two planes and the world.
    • toString

      public String toString()
      Overrides:
      toString in class Vector
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Vector
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Vector