• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java SubHyperplane类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中org.apache.commons.math3.geometry.partitioning.SubHyperplane的典型用法代码示例。如果您正苦于以下问题:Java SubHyperplane类的具体用法?Java SubHyperplane怎么用?Java SubHyperplane使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

SubHyperplane类属于org.apache.commons.math3.geometry.partitioning包,在下文中一共展示了SubHyperplane类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: addContribution

点赞 3

import org.apache.commons.math3.geometry.partitioning.SubHyperplane; //导入依赖的package包/类
/** 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));

    }

}
 

开发者ID:biocompibens,
项目名称:SME,
代码行数:28,
代码来源:PolyhedronsSet.java

示例2: boundaryFacet

点赞 3

import org.apache.commons.math3.geometry.partitioning.SubHyperplane; //导入依赖的package包/类
/** 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;
}
 

开发者ID:biocompibens,
项目名称:SME,
代码行数:23,
代码来源:PolyhedronsSet.java

示例3: apply

点赞 3

import org.apache.commons.math3.geometry.partitioning.SubHyperplane; //导入依赖的package包/类
/** {@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 Vector2D shift  = tPlane.toSubSpace((Point<Euclidean3D>) apply(oPlane.getOrigin()));

        cachedOriginal  = (Plane) original;
        cachedTransform =
                org.apache.commons.math3.geometry.euclidean.twod.Line.getTransform(1, 0, 0, 1,
                                                                                   shift.getX(),
                                                                                   shift.getY());

    }

    return ((SubLine) sub).applyTransform(cachedTransform);

}
 

开发者ID:biocompibens,
项目名称:SME,
代码行数:23,
代码来源:PolyhedronsSet.java

示例4: apply

点赞 3

import org.apache.commons.math3.geometry.partitioning.SubHyperplane; //导入依赖的package包/类
/** {@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);
}
 

开发者ID:Quanticol,
项目名称:CARMA,
代码行数:27,
代码来源:PolyhedronsSet.java

示例5: recurseTransform

点赞 3

import org.apache.commons.math3.geometry.partitioning.SubHyperplane; //导入依赖的package包/类
/** Recursively transform a BSP-tree from a sub-hyperplane.
 * @param node current BSP tree node
 * @param transformed image of the instance hyperplane by the transform
 * @param transform transform to apply
 * @return a new tree
 */
private BSPTree<T> recurseTransform(final BSPTree<T> node,
                                    final Hyperplane<S> transformed,
                                    final Transform<S, T> transform) {
    if (node.getCut() == null) {
        return new BSPTree<T>(node.getAttribute());
    }

    @SuppressWarnings("unchecked")
    BoundaryAttribute<T> attribute =
        (BoundaryAttribute<T>) node.getAttribute();
    if (attribute != null) {
        final SubHyperplane<T> tPO = (attribute.getPlusOutside() == null) ?
            null : transform.apply(attribute.getPlusOutside(), hyperplane, transformed);
        final SubHyperplane<T> tPI = (attribute.getPlusInside() == null) ?
            null : transform.apply(attribute.getPlusInside(), hyperplane, transformed);
        attribute = new BoundaryAttribute<T>(tPO, tPI);
    }

    return new BSPTree<T>(transform.apply(node.getCut(), hyperplane, transformed),
                          recurseTransform(node.getPlus(), transformed, transform),
                          recurseTransform(node.getMinus(), transformed, transform),
                          attribute);

}
 

开发者ID:SpoonLabs,
项目名称:astor,
代码行数:31,
代码来源:AbstractSubHyperplane.java

示例6: addContribution

点赞 3

import org.apache.commons.math3.geometry.partitioning.SubHyperplane; //导入依赖的package包/类
/** 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(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(new Vector3D(1.0, (Vector3D) getBarycenter(), scaled, facetB));

    }

}
 

开发者ID:SpoonLabs,
项目名称:astor,
代码行数:28,
代码来源:PolyhedronsSet.java

示例7: apply

点赞 3

import org.apache.commons.math3.geometry.partitioning.SubHyperplane; //导入依赖的package包/类
/** {@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(new Vector2D(1.0, 0.0));
        final Vector3D p01    = oPlane.toSpace(new Vector2D(0.0, 1.0));
        final Vector2D tP00   = tPlane.toSubSpace(apply(p00));
        final Vector2D tP10   = tPlane.toSubSpace(apply(p10));
        final Vector2D tP01   = tPlane.toSubSpace(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);
}
 

开发者ID:SpoonLabs,
项目名称:astor,
代码行数:27,
代码来源:PolyhedronsSet.java

示例8: addContribution

点赞 3

import org.apache.commons.math3.geometry.partitioning.SubHyperplane; //导入依赖的package包/类
/** Add he 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.getLower()) ?
                              null : (Vector2D) line.toSpace(new Vector1D(i.getLower()));
        final Vector2D end   = Double.isInfinite(i.getUpper()) ?
                              null : (Vector2D) line.toSpace(new Vector1D(i.getUpper()));
        if (reversed) {
            sorted.insert(new ComparableSegment(end, start, line.getReverse()));
        } else {
            sorted.insert(new ComparableSegment(start, end, line));
        }
    }
}
 

开发者ID:SpoonLabs,
项目名称:astor,
代码行数:23,
代码来源:PolygonsSet.java

示例9: boundaryFacet

点赞 3

import org.apache.commons.math3.geometry.partitioning.SubHyperplane; //导入依赖的package包/类
/** 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);
    @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;
}
 

开发者ID:SpoonLabs,
项目名称:astor,
代码行数:23,
代码来源:PolyhedronsSet.java

示例10: addContribution

点赞 3

import org.apache.commons.math3.geometry.partitioning.SubHyperplane; //导入依赖的package包/类
/** Add he 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(new Vector1D(i.getInf()));
        final Vector2D end   = Double.isInfinite(i.getSup()) ?
                              null : (Vector2D) line.toSpace(new Vector1D(i.getSup()));
        if (reversed) {
            sorted.insert(new ComparableSegment(end, start, line.getReverse()));
        } else {
            sorted.insert(new ComparableSegment(start, end, line));
        }
    }
}
 

开发者ID:SpoonLabs,
项目名称:astor,
代码行数:23,
代码来源:PolygonsSet.java

示例11: apply

点赞 2

import org.apache.commons.math3.geometry.partitioning.SubHyperplane; //导入依赖的package包/类
/** {@inheritDoc} */
public SubHyperplane<Sphere1D> apply(final SubHyperplane<Sphere1D> sub,
                                     final Hyperplane<Sphere2D> original,
                                     final Hyperplane<Sphere2D> transformed) {
    // as the circle is rotated, the limit angles are rotated too
    return sub;
}
 

开发者ID:biocompibens,
项目名称:SME,
代码行数:8,
代码来源:Circle.java

示例12: apply

点赞 2

import org.apache.commons.math3.geometry.partitioning.SubHyperplane; //导入依赖的package包/类
/** {@inheritDoc} */
public SubHyperplane<Euclidean1D> apply(final SubHyperplane<Euclidean1D> sub,
                                        final Hyperplane<Euclidean2D> original,
                                        final Hyperplane<Euclidean2D> transformed) {
    final OrientedPoint op     = (OrientedPoint) sub.getHyperplane();
    final Line originalLine    = (Line) original;
    final Line transformedLine = (Line) transformed;
    final Vector1D newLoc =
        transformedLine.toSubSpace(apply(originalLine.toSpace(op.getLocation())));
    return new OrientedPoint(newLoc, op.isDirect(), originalLine.tolerance).wholeHyperplane();
}
 

开发者ID:biocompibens,
项目名称:SME,
代码行数:12,
代码来源:Line.java

示例13: addContribution

点赞 2

import org.apache.commons.math3.geometry.partitioning.SubHyperplane; //导入依赖的package包/类
/** Add the contribution of a boundary facet.
 * @param sub boundary facet
 * @param node node containing segment
 * @param splitters splitters for the boundary facet
 * @param reversed if true, the facet has the inside on its plus side
 */
private void addContribution(final SubHyperplane<Euclidean2D> sub,
                             final BSPTree<Euclidean2D> node,
                             final Iterable<BSPTree<Euclidean2D>> splitters,
                             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) {

        // find the 2D points
        final Vector2D startV = Double.isInfinite(i.getInf()) ?
                                null : (Vector2D) line.toSpace((Point<Euclidean1D>) new Vector1D(i.getInf()));
        final Vector2D endV   = Double.isInfinite(i.getSup()) ?
                                null : (Vector2D) line.toSpace((Point<Euclidean1D>) new Vector1D(i.getSup()));

        // recover the connectivity information
        final BSPTree<Euclidean2D> startN = selectClosest(startV, splitters);
        final BSPTree<Euclidean2D> endN   = selectClosest(endV, splitters);

        if (reversed) {
            segments.add(new ConnectableSegment(endV, startV, line.getReverse(),
                                                node, endN, startN));
        } else {
            segments.add(new ConnectableSegment(startV, endV, line,
                                                node, startN, endN));
        }

    }
}
 

开发者ID:biocompibens,
项目名称:SME,
代码行数:38,
代码来源:PolygonsSet.java

示例14: NestedLoops

点赞 2

import org.apache.commons.math3.geometry.partitioning.SubHyperplane; //导入依赖的package包/类
/** Constructor.
 * <p>Build a tree node with neither parent nor children</p>
 * @param loop boundary loop (will be reversed in place if needed)
 * @param tolerance tolerance below which points are considered identical
 * @exception MathIllegalArgumentException if an outline has an open boundary loop
 * @since 3.3
 */
private NestedLoops(final Vector2D[] loop, final double tolerance)
    throws MathIllegalArgumentException {

    if (loop[0] == null) {
        throw new MathIllegalArgumentException(LocalizedFormats.OUTLINE_BOUNDARY_LOOP_OPEN);
    }

    this.loop       = loop;
    this.surrounded = new ArrayList<NestedLoops>();
    this.tolerance  = tolerance;

    // build the polygon defined by the loop
    final ArrayList<SubHyperplane<Euclidean2D>> edges = new ArrayList<SubHyperplane<Euclidean2D>>();
    Vector2D current = loop[loop.length - 1];
    for (int i = 0; i < loop.length; ++i) {
        final Vector2D previous = current;
        current = loop[i];
        final Line   line   = new Line(previous, current, tolerance);
        final IntervalsSet region =
            new IntervalsSet(line.toSubSpace((Point<Euclidean2D>) previous).getX(),
                             line.toSubSpace((Point<Euclidean2D>) current).getX(),
                             tolerance);
        edges.add(new SubLine(line, region));
    }
    polygon = new PolygonsSet(edges, tolerance);

    // ensure the polygon encloses a finite region of the plane
    if (Double.isInfinite(polygon.getSize())) {
        polygon = new RegionFactory<Euclidean2D>().getComplement(polygon);
        originalIsClockwise = false;
    } else {
        originalIsClockwise = true;
    }

}
 

开发者ID:biocompibens,
项目名称:SME,
代码行数:43,
代码来源:NestedLoops.java

示例15: split

点赞 2

import org.apache.commons.math3.geometry.partitioning.SubHyperplane; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public SplitSubHyperplane<Euclidean2D> split(final Hyperplane<Euclidean2D> hyperplane) {

    final Line    thisLine  = (Line) getHyperplane();
    final Line    otherLine = (Line) hyperplane;
    final Vector2D crossing = thisLine.intersection(otherLine);
    final double tolerance  = thisLine.getTolerance();

    if (crossing == null) {
        // the lines are parallel
        final double global = otherLine.getOffset(thisLine);
        return (global < -1.0e-10) ?
               new SplitSubHyperplane<Euclidean2D>(null, this) :
               new SplitSubHyperplane<Euclidean2D>(this, null);
    }

    // the lines do intersect
    final boolean direct = FastMath.sin(thisLine.getAngle() - otherLine.getAngle()) < 0;
    final Vector1D x      = thisLine.toSubSpace((Point<Euclidean2D>) crossing);
    final SubHyperplane<Euclidean1D> subPlus  =
            new OrientedPoint(x, !direct, tolerance).wholeHyperplane();
    final SubHyperplane<Euclidean1D> subMinus =
            new OrientedPoint(x,  direct, tolerance).wholeHyperplane();

    final BSPTree<Euclidean1D> splitTree = getRemainingRegion().getTree(false).split(subMinus);
    final BSPTree<Euclidean1D> plusTree  = getRemainingRegion().isEmpty(splitTree.getPlus()) ?
                                           new BSPTree<Euclidean1D>(Boolean.FALSE) :
                                           new BSPTree<Euclidean1D>(subPlus, new BSPTree<Euclidean1D>(Boolean.FALSE),
                                                                    splitTree.getPlus(), null);
    final BSPTree<Euclidean1D> minusTree = getRemainingRegion().isEmpty(splitTree.getMinus()) ?
                                           new BSPTree<Euclidean1D>(Boolean.FALSE) :
                                           new BSPTree<Euclidean1D>(subMinus, new BSPTree<Euclidean1D>(Boolean.FALSE),
                                                                    splitTree.getMinus(), null);

    return new SplitSubHyperplane<Euclidean2D>(new SubLine(thisLine.copySelf(), new IntervalsSet(plusTree, tolerance)),
                                               new SubLine(thisLine.copySelf(), new IntervalsSet(minusTree, tolerance)));

}
 

开发者ID:Quanticol,
项目名称:CARMA,
代码行数:40,
代码来源:SubLine.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)