org.apache.commons.math3.geometry.Point Java Examples

The following examples show how to use org.apache.commons.math3.geometry.Point. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NPEfix_00119_t.java    From coming with MIT License 6 votes vote down vote up
/** Get the cells whose cut sub-hyperplanes are close to the point.
 * @param point point to check
 * @param maxOffset offset below which a cut sub-hyperplane is considered
 * close to the point (in absolute value)
 * @param close list to fill
 */
private void recurseCloseCuts(final Point<S> point, final double maxOffset,
                              final List<BSPTree<S>> close) {
    if (cut != null) {

        // position of the point with respect to the cut hyperplane
        final double offset = cut.getHyperplane().getOffset(point);

        if (offset < -maxOffset) {
            // point is on the minus side of the cut hyperplane
            minus.recurseCloseCuts(point, maxOffset, close);
        } else if (offset > maxOffset) {
            // point is on the plus side of the cut hyperplane
            plus.recurseCloseCuts(point, maxOffset, close);
        } else {
            // point is close to the cut hyperplane
            close.add(this);
            minus.recurseCloseCuts(point, maxOffset, close);
            plus.recurseCloseCuts(point, maxOffset, close);
        }

    }
}
 
Example #2
Source File: NPEfix_00129_s.java    From coming with MIT License 6 votes vote down vote up
/** Get the cell to which a point belongs.
 * <p>If the returned cell is a leaf node the points belongs to the
 * interior of the node, if the cell is an internal node the points
 * belongs to the node cut sub-hyperplane.</p>
 * @param point point to check
 * @param tolerance tolerance below which points close to a cut hyperplane
 * are considered to belong to the hyperplane itself
 * @return the tree cell to which the point belongs
 */
public BSPTree<S> getCell(final Point<S> point, final double tolerance) {

    if (cut == null) {
        return this;
    }

    // position of the point with respect to the cut hyperplane
    final double offset = cut.getHyperplane().getOffset(point);

    if (FastMath.abs(offset) < tolerance) {
        return this;
    } else if (offset <= 0) {
        // point is on the minus side of the cut hyperplane
        return minus.getCell(point, tolerance);
    } else {
        // point is on the plus side of the cut hyperplane
        return plus.getCell(point, tolerance);
    }

}
 
Example #3
Source File: NPEfix_00129_s.java    From coming with MIT License 6 votes vote down vote up
/** Get the cells whose cut sub-hyperplanes are close to the point.
 * @param point point to check
 * @param maxOffset offset below which a cut sub-hyperplane is considered
 * close to the point (in absolute value)
 * @param close list to fill
 */
private void recurseCloseCuts(final Point<S> point, final double maxOffset,
                              final List<BSPTree<S>> close) {
    if (cut != null) {

        // position of the point with respect to the cut hyperplane
        final double offset = cut.getHyperplane().getOffset(point);

        if (offset < -maxOffset) {
            // point is on the minus side of the cut hyperplane
            minus.recurseCloseCuts(point, maxOffset, close);
        } else if (offset > maxOffset) {
            // point is on the plus side of the cut hyperplane
            plus.recurseCloseCuts(point, maxOffset, close);
        } else {
            // point is close to the cut hyperplane
            close.add(this);
            minus.recurseCloseCuts(point, maxOffset, close);
            plus.recurseCloseCuts(point, maxOffset, close);
        }

    }
}
 
Example #4
Source File: NPEfix10_ten_t.java    From coming with MIT License 6 votes vote down vote up
/** Check if a point belongs to the boundary part of a node.
 * @param point point to check
 * @param node node containing the boundary facet to check
 * @return the boundary facet this points belongs to (or null if it
 * does not belong to any boundary facet)
 */
private SubHyperplane<Euclidean3D> boundaryFacet(final Vector3D point,
                                                 final BSPTree<Euclidean3D> node) {
    final Vector2D point2D = ((Plane) node.getCut().getHyperplane()).toSubSpace((Point<Euclidean3D>) point);
    @SuppressWarnings("unchecked")
    final BoundaryAttribute<Euclidean3D> attribute =
            (BoundaryAttribute<Euclidean3D>) node.getAttribute();
    if ((attribute.getPlusOutside() != null) &&
            (((SubPlane) attribute.getPlusOutside()).getRemainingRegion().checkPoint(point2D) == Location.INSIDE)) {
        return attribute.getPlusOutside();
    }
    if ((attribute.getPlusInside() != null) &&
            (((SubPlane) attribute.getPlusInside()).getRemainingRegion().checkPoint(point2D) == Location.INSIDE)) {
        return attribute.getPlusInside();
    }
    return null;
}
 
Example #5
Source File: NPEfix_00125_t.java    From coming with MIT License 6 votes vote down vote up
/** Get the cells whose cut sub-hyperplanes are close to the point.
 * @param point point to check
 * @param maxOffset offset below which a cut sub-hyperplane is considered
 * close to the point (in absolute value)
 * @param close list to fill
 */
private void recurseCloseCuts(final Point<S> point, final double maxOffset,
                              final List<BSPTree<S>> close) {
    if (cut != null) {

        // position of the point with respect to the cut hyperplane
        final double offset = cut.getHyperplane().getOffset(point);

        if (offset < -maxOffset) {
            // point is on the minus side of the cut hyperplane
            minus.recurseCloseCuts(point, maxOffset, close);
        } else if (offset > maxOffset) {
            // point is on the plus side of the cut hyperplane
            plus.recurseCloseCuts(point, maxOffset, close);
        } else {
            // point is close to the cut hyperplane
            close.add(this);
            minus.recurseCloseCuts(point, maxOffset, close);
            plus.recurseCloseCuts(point, maxOffset, close);
        }

    }
}
 
Example #6
Source File: NPEfix11_eleven_t.java    From coming with MIT License 6 votes vote down vote up
/** Add the contribution of a boundary facet.
 * @param sub boundary facet
 * @param reversed if true, the facet has the inside on its plus side
 */
private void addContribution(final SubHyperplane<Euclidean2D> sub, final boolean reversed) {
    @SuppressWarnings("unchecked")
    final AbstractSubHyperplane<Euclidean2D, Euclidean1D> absSub =
            (AbstractSubHyperplane<Euclidean2D, Euclidean1D>) sub;
    final Line line      = (Line) sub.getHyperplane();
    final List<Interval> intervals = ((IntervalsSet) absSub.getRemainingRegion()).asList();
    for (final Interval i : intervals) {
        final Vector2D start = Double.isInfinite(i.getInf()) ?
                null : (Vector2D) line.toSpace((Point<Euclidean1D>) new Vector1D(i.getInf()));
        final Vector2D end   = Double.isInfinite(i.getSup()) ?
                null : (Vector2D) line.toSpace((Point<Euclidean1D>) new Vector1D(i.getSup()));
        if (reversed) {
            sorted.insert(new ComparableSegment(end, start, line.getReverse()));
        } else {
            sorted.insert(new ComparableSegment(start, end, line));
        }
    }
}
 
Example #7
Source File: NPEfix_00124_t.java    From coming with MIT License 6 votes vote down vote up
/** Get the cells whose cut sub-hyperplanes are close to the point.
 * @param point point to check
 * @param maxOffset offset below which a cut sub-hyperplane is considered
 * close to the point (in absolute value)
 * @param close list to fill
 */
private void recurseCloseCuts(final Point<S> point, final double maxOffset,
                              final List<BSPTree<S>> close) {
    if (cut != null) {

        // position of the point with respect to the cut hyperplane
        final double offset = cut.getHyperplane().getOffset(point);

        if (offset < -maxOffset) {
            // point is on the minus side of the cut hyperplane
            minus.recurseCloseCuts(point, maxOffset, close);
        } else if (offset > maxOffset) {
            // point is on the plus side of the cut hyperplane
            plus.recurseCloseCuts(point, maxOffset, close);
        } else {
            // point is close to the cut hyperplane
            close.add(this);
            minus.recurseCloseCuts(point, maxOffset, close);
            plus.recurseCloseCuts(point, maxOffset, close);
        }

    }
}
 
Example #8
Source File: NPEfix_00125_s.java    From coming with MIT License 6 votes vote down vote up
/** Get the cells whose cut sub-hyperplanes are close to the point.
 * @param point point to check
 * @param maxOffset offset below which a cut sub-hyperplane is considered
 * close to the point (in absolute value)
 * @param close list to fill
 */
private void recurseCloseCuts(final Point<S> point, final double maxOffset,
                              final List<BSPTree<S>> close) {
    if (cut != null) {

        // position of the point with respect to the cut hyperplane
        final double offset = cut.getHyperplane().getOffset(point);

        if (offset < -maxOffset) {
            // point is on the minus side of the cut hyperplane
            minus.recurseCloseCuts(point, maxOffset, close);
        } else if (offset > maxOffset) {
            // point is on the plus side of the cut hyperplane
            plus.recurseCloseCuts(point, maxOffset, close);
        } else {
            // point is close to the cut hyperplane
            close.add(this);
            minus.recurseCloseCuts(point, maxOffset, close);
            plus.recurseCloseCuts(point, maxOffset, close);
        }

    }
}
 
Example #9
Source File: NPEfix_00124_s.java    From coming with MIT License 6 votes vote down vote up
/** Get the cells whose cut sub-hyperplanes are close to the point.
 * @param point point to check
 * @param maxOffset offset below which a cut sub-hyperplane is considered
 * close to the point (in absolute value)
 * @param close list to fill
 */
private void recurseCloseCuts(final Point<S> point, final double maxOffset,
                              final List<BSPTree<S>> close) {
    if (cut != null) {

        // position of the point with respect to the cut hyperplane
        final double offset = cut.getHyperplane().getOffset(point);

        if (offset < -maxOffset) {
            // point is on the minus side of the cut hyperplane
            minus.recurseCloseCuts(point, maxOffset, close);
        } else if (offset > maxOffset) {
            // point is on the plus side of the cut hyperplane
            plus.recurseCloseCuts(point, maxOffset, close);
        } else {
            // point is close to the cut hyperplane
            close.add(this);
            minus.recurseCloseCuts(point, maxOffset, close);
            plus.recurseCloseCuts(point, maxOffset, close);
        }

    }
}
 
Example #10
Source File: NPEfix_00119_s.java    From coming with MIT License 6 votes vote down vote up
/** Get the cell to which a point belongs.
 * <p>If the returned cell is a leaf node the points belongs to the
 * interior of the node, if the cell is an internal node the points
 * belongs to the node cut sub-hyperplane.</p>
 * @param point point to check
 * @param tolerance tolerance below which points close to a cut hyperplane
 * are considered to belong to the hyperplane itself
 * @return the tree cell to which the point belongs
 */
public BSPTree<S> getCell(final Point<S> point, final double tolerance) {

    if (cut == null) {
        return this;
    }

    // position of the point with respect to the cut hyperplane
    final double offset = cut.getHyperplane().getOffset(point);

    if (FastMath.abs(offset) < tolerance) {
        return this;
    } else if (offset <= 0) {
        // point is on the minus side of the cut hyperplane
        return minus.getCell(point, tolerance);
    } else {
        // point is on the plus side of the cut hyperplane
        return plus.getCell(point, tolerance);
    }

}
 
Example #11
Source File: NPEfix_00120_t.java    From coming with MIT License 6 votes vote down vote up
/** Get the cell to which a point belongs.
 * <p>If the returned cell is a leaf node the points belongs to the
 * interior of the node, if the cell is an internal node the points
 * belongs to the node cut sub-hyperplane.</p>
 * @param point point to check
 * @param tolerance tolerance below which points close to a cut hyperplane
 * are considered to belong to the hyperplane itself
 * @return the tree cell to which the point belongs
 */
public BSPTree<S> getCell(final Point<S> point, final double tolerance) {

    if (cut == null) {
        return this;
    }

    // position of the point with respect to the cut hyperplane
    final double offset = cut.getHyperplane().getOffset(point);

    if (FastMath.abs(offset) < tolerance) {
        return this;
    } else if (offset <= 0) {
        // point is on the minus side of the cut hyperplane
        return minus.getCell(point, tolerance);
    } else {
        // point is on the plus side of the cut hyperplane
        return plus.getCell(point, tolerance);
    }

}
 
Example #12
Source File: NPEfix_00123_s.java    From coming with MIT License 6 votes vote down vote up
/** Get the cell to which a point belongs.
 * <p>If the returned cell is a leaf node the points belongs to the
 * interior of the node, if the cell is an internal node the points
 * belongs to the node cut sub-hyperplane.</p>
 * @param point point to check
 * @param tolerance tolerance below which points close to a cut hyperplane
 * are considered to belong to the hyperplane itself
 * @return the tree cell to which the point belongs
 */
public BSPTree<S> getCell(final Point<S> point, final double tolerance) {

    if (cut == null) {
        return this;
    }

    // position of the point with respect to the cut hyperplane
    final double offset = cut.getHyperplane().getOffset(point);

    if (FastMath.abs(offset) < tolerance) {
        return this;
    } else if (offset <= 0) {
        // point is on the minus side of the cut hyperplane
        return minus.getCell(point, tolerance);
    } else {
        // point is on the plus side of the cut hyperplane
        return plus.getCell(point, tolerance);
    }

}
 
Example #13
Source File: NPEfix_00120_t.java    From coming with MIT License 6 votes vote down vote up
/** Get the cells whose cut sub-hyperplanes are close to the point.
 * @param point point to check
 * @param maxOffset offset below which a cut sub-hyperplane is considered
 * close to the point (in absolute value)
 * @param close list to fill
 */
private void recurseCloseCuts(final Point<S> point, final double maxOffset,
                              final List<BSPTree<S>> close) {
    if (cut != null) {

        // position of the point with respect to the cut hyperplane
        final double offset = cut.getHyperplane().getOffset(point);

        if (offset < -maxOffset) {
            // point is on the minus side of the cut hyperplane
            minus.recurseCloseCuts(point, maxOffset, close);
        } else if (offset > maxOffset) {
            // point is on the plus side of the cut hyperplane
            plus.recurseCloseCuts(point, maxOffset, close);
        } else {
            // point is close to the cut hyperplane
            close.add(this);
            minus.recurseCloseCuts(point, maxOffset, close);
            plus.recurseCloseCuts(point, maxOffset, close);
        }

    }
}
 
Example #14
Source File: NPEfix11_eleven_s.java    From coming with MIT License 6 votes vote down vote up
/** Add the contribution of a boundary facet.
 * @param sub boundary facet
 * @param reversed if true, the facet has the inside on its plus side
 */
private void addContribution(final SubHyperplane<Euclidean2D> sub, final boolean reversed) {
    @SuppressWarnings("unchecked")
    final AbstractSubHyperplane<Euclidean2D, Euclidean1D> absSub =
            (AbstractSubHyperplane<Euclidean2D, Euclidean1D>) sub;
    final Line line      = (Line) sub.getHyperplane();
    final List<Interval> intervals = ((IntervalsSet) absSub.getRemainingRegion()).asList();
    for (final Interval i : intervals) {
        final Vector2D start = Double.isInfinite(i.getInf()) ?
                null : (Vector2D) line.toSpace((Point<Euclidean1D>) new Vector1D(i.getInf()));
        final Vector2D end   = Double.isInfinite(i.getSup()) ?
                null : (Vector2D) line.toSpace((Point<Euclidean1D>) new Vector1D(i.getSup()));
        if (reversed) {
            sorted.insert(new ComparableSegment(end, start, line.getReverse()));
        } else {
            sorted.insert(new ComparableSegment(start, end, line));
        }
    }
}
 
Example #15
Source File: NPEfix10_ten_s.java    From coming with MIT License 6 votes vote down vote up
/** {@inheritDoc} */
public SubHyperplane<Euclidean2D> apply(final SubHyperplane<Euclidean2D> sub,
                                        final Hyperplane<Euclidean3D> original,
                                        final Hyperplane<Euclidean3D> transformed) {
    if (original != cachedOriginal) {
        // we have changed hyperplane, reset the in-hyperplane transform

        final Plane    oPlane = (Plane) original;
        final Plane    tPlane = (Plane) transformed;
        final Vector3D p00    = oPlane.getOrigin();
        final Vector3D p10    = oPlane.toSpace((Point<Euclidean2D>) new Vector2D(1.0, 0.0));
        final Vector3D p01    = oPlane.toSpace((Point<Euclidean2D>) new Vector2D(0.0, 1.0));
        final Vector2D tP00   = tPlane.toSubSpace((Point<Euclidean3D>) apply(p00));
        final Vector2D tP10   = tPlane.toSubSpace((Point<Euclidean3D>) apply(p10));
        final Vector2D tP01   = tPlane.toSubSpace((Point<Euclidean3D>) apply(p01));
        final AffineTransform at =
                new AffineTransform(tP10.getX() - tP00.getX(), tP10.getY() - tP00.getY(),
                        tP01.getX() - tP00.getX(), tP01.getY() - tP00.getY(),
                        tP00.getX(), tP00.getY());

        cachedOriginal  = (Plane) original;
        cachedTransform = org.apache.commons.math3.geometry.euclidean.twod.Line.getTransform(at);

    }
    return ((SubLine) sub).applyTransform(cachedTransform);
}
 
Example #16
Source File: GetSupportPointsEvaluator.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
@Override
public Object doWork(Object value) throws IOException {
  if(!(value instanceof EnclosingBall)){
    throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - found type %s for value, expecting an EnclosingBall",toExpression(constructingFactory), value.getClass().getSimpleName()));
  } else {
    @SuppressWarnings({"rawtypes"})
    EnclosingBall enclosingBall = (EnclosingBall)value;
    @SuppressWarnings({"rawtypes"})
    Point[] points = enclosingBall.getSupport();
    double[][] data = new double[points.length][2];
    int i=0;
    for(@SuppressWarnings({"rawtypes"})Point point : points) {
      Vector2D eu = (Vector2D)point;
      data[i][0] = eu.getX();
      data[i][1] = eu.getY();
      ++i;
    }

    return new Matrix(data);
  }
}
 
Example #17
Source File: NPEfix_00122_t.java    From coming with MIT License 6 votes vote down vote up
/** Get the cell to which a point belongs.
 * <p>If the returned cell is a leaf node the points belongs to the
 * interior of the node, if the cell is an internal node the points
 * belongs to the node cut sub-hyperplane.</p>
 * @param point point to check
 * @param tolerance tolerance below which points close to a cut hyperplane
 * are considered to belong to the hyperplane itself
 * @return the tree cell to which the point belongs
 */
public BSPTree<S> getCell(final Point<S> point, final double tolerance) {

    if (cut == null) {
        return this;
    }

    // position of the point with respect to the cut hyperplane
    final double offset = cut.getHyperplane().getOffset(point);

    if (FastMath.abs(offset) < tolerance) {
        return this;
    } else if (offset <= 0) {
        // point is on the minus side of the cut hyperplane
        return minus.getCell(point, tolerance);
    } else {
        // point is on the plus side of the cut hyperplane
        return plus.getCell(point, tolerance);
    }

}
 
Example #18
Source File: NPEfix10_ten_s.java    From coming with MIT License 6 votes vote down vote up
/** Add he contribution of a boundary facet.
 * @param facet boundary facet
 * @param reversed if true, the facet has the inside on its plus side
 */
private void addContribution(final SubHyperplane<Euclidean3D> facet, final boolean reversed) {

    final Region<Euclidean2D> polygon = ((SubPlane) facet).getRemainingRegion();
    final double area    = polygon.getSize();

    if (Double.isInfinite(area)) {
        setSize(Double.POSITIVE_INFINITY);
        setBarycenter((Point<Euclidean3D>) Vector3D.NaN);
    } else {

        final Plane    plane  = (Plane) facet.getHyperplane();
        final Vector3D facetB = plane.toSpace(polygon.getBarycenter());
        double   scaled = area * facetB.dotProduct(plane.getNormal());
        if (reversed) {
            scaled = -scaled;
        }

        setSize(getSize() + scaled);
        setBarycenter((Point<Euclidean3D>) new Vector3D(1.0, (Vector3D) getBarycenter(), scaled, facetB));

    }

}
 
Example #19
Source File: NPEfix_00122_t.java    From coming with MIT License 6 votes vote down vote up
/** Get the cells whose cut sub-hyperplanes are close to the point.
 * @param point point to check
 * @param maxOffset offset below which a cut sub-hyperplane is considered
 * close to the point (in absolute value)
 * @param close list to fill
 */
private void recurseCloseCuts(final Point<S> point, final double maxOffset,
                              final List<BSPTree<S>> close) {
    if (cut != null) {

        // position of the point with respect to the cut hyperplane
        final double offset = cut.getHyperplane().getOffset(point);

        if (offset < -maxOffset) {
            // point is on the minus side of the cut hyperplane
            minus.recurseCloseCuts(point, maxOffset, close);
        } else if (offset > maxOffset) {
            // point is on the plus side of the cut hyperplane
            plus.recurseCloseCuts(point, maxOffset, close);
        } else {
            // point is close to the cut hyperplane
            close.add(this);
            minus.recurseCloseCuts(point, maxOffset, close);
            plus.recurseCloseCuts(point, maxOffset, close);
        }

    }
}
 
Example #20
Source File: NPEfix_00122_s.java    From coming with MIT License 6 votes vote down vote up
/** Get the cell to which a point belongs.
 * <p>If the returned cell is a leaf node the points belongs to the
 * interior of the node, if the cell is an internal node the points
 * belongs to the node cut sub-hyperplane.</p>
 * @param point point to check
 * @param tolerance tolerance below which points close to a cut hyperplane
 * are considered to belong to the hyperplane itself
 * @return the tree cell to which the point belongs
 */
public BSPTree<S> getCell(final Point<S> point, final double tolerance) {

    if (cut == null) {
        return this;
    }

    // position of the point with respect to the cut hyperplane
    final double offset = cut.getHyperplane().getOffset(point);

    if (FastMath.abs(offset) < tolerance) {
        return this;
    } else if (offset <= 0) {
        // point is on the minus side of the cut hyperplane
        return minus.getCell(point, tolerance);
    } else {
        // point is on the plus side of the cut hyperplane
        return plus.getCell(point, tolerance);
    }

}
 
Example #21
Source File: NPEfix_00119_t.java    From coming with MIT License 6 votes vote down vote up
/** Get the cell to which a point belongs.
 * <p>If the returned cell is a leaf node the points belongs to the
 * interior of the node, if the cell is an internal node the points
 * belongs to the node cut sub-hyperplane.</p>
 * @param point point to check
 * @param tolerance tolerance below which points close to a cut hyperplane
 * are considered to belong to the hyperplane itself
 * @return the tree cell to which the point belongs
 */
public BSPTree<S> getCell(final Point<S> point, final double tolerance) {

    if (cut == null) {
        return this;
    }

    // position of the point with respect to the cut hyperplane
    final double offset = cut.getHyperplane().getOffset(point);

    if (FastMath.abs(offset) < tolerance) {
        return this;
    } else if (offset <= 0) {
        // point is on the minus side of the cut hyperplane
        return minus.getCell(point, tolerance);
    } else {
        // point is on the plus side of the cut hyperplane
        return plus.getCell(point, tolerance);
    }

}
 
Example #22
Source File: NPEfix_00121_s.java    From coming with MIT License 6 votes vote down vote up
/** Get the cell to which a point belongs.
 * <p>If the returned cell is a leaf node the points belongs to the
 * interior of the node, if the cell is an internal node the points
 * belongs to the node cut sub-hyperplane.</p>
 * @param point point to check
 * @param tolerance tolerance below which points close to a cut hyperplane
 * are considered to belong to the hyperplane itself
 * @return the tree cell to which the point belongs
 */
public BSPTree<S> getCell(final Point<S> point, final double tolerance) {

    if (cut == null) {
        return this;
    }

    // position of the point with respect to the cut hyperplane
    final double offset = cut.getHyperplane().getOffset(point);

    if (FastMath.abs(offset) < tolerance) {
        return this;
    } else if (offset <= 0) {
        // point is on the minus side of the cut hyperplane
        return minus.getCell(point, tolerance);
    } else {
        // point is on the plus side of the cut hyperplane
        return plus.getCell(point, tolerance);
    }

}
 
Example #23
Source File: NPEfix_00123_t.java    From coming with MIT License 6 votes vote down vote up
/** Get the cell to which a point belongs.
 * <p>If the returned cell is a leaf node the points belongs to the
 * interior of the node, if the cell is an internal node the points
 * belongs to the node cut sub-hyperplane.</p>
 * @param point point to check
 * @param tolerance tolerance below which points close to a cut hyperplane
 * are considered to belong to the hyperplane itself
 * @return the tree cell to which the point belongs
 */
public BSPTree<S> getCell(final Point<S> point, final double tolerance) {

    if (cut == null) {
        return this;
    }

    // position of the point with respect to the cut hyperplane
    final double offset = cut.getHyperplane().getOffset(point);

    if (FastMath.abs(offset) < tolerance) {
        return this;
    } else if (offset <= 0) {
        // point is on the minus side of the cut hyperplane
        return minus.getCell(point, tolerance);
    } else {
        // point is on the plus side of the cut hyperplane
        return plus.getCell(point, tolerance);
    }

}
 
Example #24
Source File: NPEfix_00121_s.java    From coming with MIT License 6 votes vote down vote up
/** Get the cells whose cut sub-hyperplanes are close to the point.
 * @param point point to check
 * @param maxOffset offset below which a cut sub-hyperplane is considered
 * close to the point (in absolute value)
 * @param close list to fill
 */
private void recurseCloseCuts(final Point<S> point, final double maxOffset,
                              final List<BSPTree<S>> close) {
    if (cut != null) {

        // position of the point with respect to the cut hyperplane
        final double offset = cut.getHyperplane().getOffset(point);

        if (offset < -maxOffset) {
            // point is on the minus side of the cut hyperplane
            minus.recurseCloseCuts(point, maxOffset, close);
        } else if (offset > maxOffset) {
            // point is on the plus side of the cut hyperplane
            plus.recurseCloseCuts(point, maxOffset, close);
        } else {
            // point is close to the cut hyperplane
            close.add(this);
            minus.recurseCloseCuts(point, maxOffset, close);
            plus.recurseCloseCuts(point, maxOffset, close);
        }

    }
}
 
Example #25
Source File: NPEfix_00127_t.java    From coming with MIT License 6 votes vote down vote up
/** Get the cells whose cut sub-hyperplanes are close to the point.
 * @param point point to check
 * @param maxOffset offset below which a cut sub-hyperplane is considered
 * close to the point (in absolute value)
 * @param close list to fill
 */
private void recurseCloseCuts(final Point<S> point, final double maxOffset,
                              final List<BSPTree<S>> close) {
    if (cut != null) {

        // position of the point with respect to the cut hyperplane
        final double offset = cut.getHyperplane().getOffset(point);

        if (offset < -maxOffset) {
            // point is on the minus side of the cut hyperplane
            minus.recurseCloseCuts(point, maxOffset, close);
        } else if (offset > maxOffset) {
            // point is on the plus side of the cut hyperplane
            plus.recurseCloseCuts(point, maxOffset, close);
        } else {
            // point is close to the cut hyperplane
            close.add(this);
            minus.recurseCloseCuts(point, maxOffset, close);
            plus.recurseCloseCuts(point, maxOffset, close);
        }

    }
}
 
Example #26
Source File: NPEfix_00121_t.java    From coming with MIT License 6 votes vote down vote up
/** Get the cell to which a point belongs.
 * <p>If the returned cell is a leaf node the points belongs to the
 * interior of the node, if the cell is an internal node the points
 * belongs to the node cut sub-hyperplane.</p>
 * @param point point to check
 * @param tolerance tolerance below which points close to a cut hyperplane
 * are considered to belong to the hyperplane itself
 * @return the tree cell to which the point belongs
 */
public BSPTree<S> getCell(final Point<S> point, final double tolerance) {

    if (cut == null) {
        return this;
    }

    // position of the point with respect to the cut hyperplane
    final double offset = cut.getHyperplane().getOffset(point);

    if (FastMath.abs(offset) < tolerance) {
        return this;
    } else if (offset <= 0) {
        // point is on the minus side of the cut hyperplane
        return minus.getCell(point, tolerance);
    } else {
        // point is on the plus side of the cut hyperplane
        return plus.getCell(point, tolerance);
    }

}
 
Example #27
Source File: NPEfix_00121_t.java    From coming with MIT License 6 votes vote down vote up
/** Get the cells whose cut sub-hyperplanes are close to the point.
 * @param point point to check
 * @param maxOffset offset below which a cut sub-hyperplane is considered
 * close to the point (in absolute value)
 * @param close list to fill
 */
private void recurseCloseCuts(final Point<S> point, final double maxOffset,
                              final List<BSPTree<S>> close) {
    if (cut != null) {

        // position of the point with respect to the cut hyperplane
        final double offset = cut.getHyperplane().getOffset(point);

        if (offset < -maxOffset) {
            // point is on the minus side of the cut hyperplane
            minus.recurseCloseCuts(point, maxOffset, close);
        } else if (offset > maxOffset) {
            // point is on the plus side of the cut hyperplane
            plus.recurseCloseCuts(point, maxOffset, close);
        } else {
            // point is close to the cut hyperplane
            close.add(this);
            minus.recurseCloseCuts(point, maxOffset, close);
            plus.recurseCloseCuts(point, maxOffset, close);
        }

    }
}
 
Example #28
Source File: NPEfix_00127_t.java    From coming with MIT License 6 votes vote down vote up
/** Get the cell to which a point belongs.
 * <p>If the returned cell is a leaf node the points belongs to the
 * interior of the node, if the cell is an internal node the points
 * belongs to the node cut sub-hyperplane.</p>
 * @param point point to check
 * @param tolerance tolerance below which points close to a cut hyperplane
 * are considered to belong to the hyperplane itself
 * @return the tree cell to which the point belongs
 */
public BSPTree<S> getCell(final Point<S> point, final double tolerance) {

    if (cut == null) {
        return this;
    }

    // position of the point with respect to the cut hyperplane
    final double offset = cut.getHyperplane().getOffset(point);

    if (FastMath.abs(offset) < tolerance) {
        return this;
    } else if (offset <= 0) {
        // point is on the minus side of the cut hyperplane
        return minus.getCell(point, tolerance);
    } else {
        // point is on the plus side of the cut hyperplane
        return plus.getCell(point, tolerance);
    }

}
 
Example #29
Source File: NPEfix_00127_s.java    From coming with MIT License 6 votes vote down vote up
/** Get the cell to which a point belongs.
 * <p>If the returned cell is a leaf node the points belongs to the
 * interior of the node, if the cell is an internal node the points
 * belongs to the node cut sub-hyperplane.</p>
 * @param point point to check
 * @param tolerance tolerance below which points close to a cut hyperplane
 * are considered to belong to the hyperplane itself
 * @return the tree cell to which the point belongs
 */
public BSPTree<S> getCell(final Point<S> point, final double tolerance) {

    if (cut == null) {
        return this;
    }

    // position of the point with respect to the cut hyperplane
    final double offset = cut.getHyperplane().getOffset(point);

    if (FastMath.abs(offset) < tolerance) {
        return this;
    } else if (offset <= 0) {
        // point is on the minus side of the cut hyperplane
        return minus.getCell(point, tolerance);
    } else {
        // point is on the plus side of the cut hyperplane
        return plus.getCell(point, tolerance);
    }

}
 
Example #30
Source File: NPEfix_00123_t.java    From coming with MIT License 6 votes vote down vote up
/** Get the cells whose cut sub-hyperplanes are close to the point.
 * @param point point to check
 * @param maxOffset offset below which a cut sub-hyperplane is considered
 * close to the point (in absolute value)
 * @param close list to fill
 */
private void recurseCloseCuts(final Point<S> point, final double maxOffset,
                              final List<BSPTree<S>> close) {
    if (cut != null) {

        // position of the point with respect to the cut hyperplane
        final double offset = cut.getHyperplane().getOffset(point);

        if (offset < -maxOffset) {
            // point is on the minus side of the cut hyperplane
            minus.recurseCloseCuts(point, maxOffset, close);
        } else if (offset > maxOffset) {
            // point is on the plus side of the cut hyperplane
            plus.recurseCloseCuts(point, maxOffset, close);
        } else {
            // point is close to the cut hyperplane
            close.add(this);
            minus.recurseCloseCuts(point, maxOffset, close);
            plus.recurseCloseCuts(point, maxOffset, close);
        }

    }
}