当前位置: 首页>>代码示例>>Java>>正文


Java MathUtils.normalizeAngle方法代码示例

本文整理汇总了Java中org.apache.commons.math3.util.MathUtils.normalizeAngle方法的典型用法代码示例。如果您正苦于以下问题:Java MathUtils.normalizeAngle方法的具体用法?Java MathUtils.normalizeAngle怎么用?Java MathUtils.normalizeAngle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.math3.util.MathUtils的用法示例。


在下文中一共展示了MathUtils.normalizeAngle方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: Arc

import org.apache.commons.math3.util.MathUtils; //导入方法依赖的package包/类
/** Simple constructor.
 * <p>
 * If either {@code lower} is equals to {@code upper} or
 * the interval exceeds \( 2 \pi \), the arc is considered
 * to be the full circle and its initial defining boundaries
 * will be forgotten. {@code lower} is not allowed to be
 * greater than {@code upper} (an exception is thrown in this case).
 * {@code lower} will be canonicalized between 0 and \( 2 \pi \), and
 * upper shifted accordingly, so the {@link #getInf()} and {@link #getSup()}
 * may not return the value used at instance construction.
 * </p>
 * @param lower lower angular bound of the arc
 * @param upper upper angular bound of the arc
 * @param tolerance tolerance below which angles are considered identical
 * @exception NumberIsTooLargeException if lower is greater than upper
 */
public Arc(final double lower, final double upper, final double tolerance)
    throws NumberIsTooLargeException {
    this.tolerance = tolerance;
    if (Precision.equals(lower, upper, 0) || (upper - lower) >= MathUtils.TWO_PI) {
        // the arc must cover the whole circle
        this.lower  = 0;
        this.upper  = MathUtils.TWO_PI;
        this.middle = FastMath.PI;
    } else  if (lower <= upper) {
        this.lower  = MathUtils.normalizeAngle(lower, FastMath.PI);
        this.upper  = this.lower + (upper - lower);
        this.middle = 0.5 * (this.lower + this.upper);
    } else {
        throw new NumberIsTooLargeException(LocalizedFormats.ENDPOINTS_NOT_AN_INTERVAL,
                                            lower, upper, true);
    }
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:34,代码来源:Arc.java

示例2: checkPoint

import org.apache.commons.math3.util.MathUtils; //导入方法依赖的package包/类
/** Check a point with respect to the arc.
 * @param point point to check
 * @return a code representing the point status: either {@link
 * Location#INSIDE}, {@link Location#OUTSIDE} or {@link Location#BOUNDARY}
 */
public Location checkPoint(final double point) {
    final double normalizedPoint = MathUtils.normalizeAngle(point, middle);
    if (normalizedPoint < lower - tolerance || normalizedPoint > upper + tolerance) {
        return Location.OUTSIDE;
    } else if (normalizedPoint > lower + tolerance && normalizedPoint < upper - tolerance) {
        return Location.INSIDE;
    } else {
        return (getSize() >= MathUtils.TWO_PI - tolerance) ? Location.INSIDE : Location.BOUNDARY;
    }
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:16,代码来源:Arc.java

示例3: Line

import org.apache.commons.math3.util.MathUtils; //导入方法依赖的package包/类
/** Copy constructor.
 * <p>The created instance is completely independent from the
 * original instance, it is a deep copy.</p>
 * @param line line to copy
 */
public Line(final Line line) {
    angle        = MathUtils.normalizeAngle(line.angle, FastMath.PI);
    cos          = line.cos;
    sin          = line.sin;
    originOffset = line.originOffset;
    tolerance    = line.tolerance;
    reverse      = null;
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:14,代码来源:Line.java

示例4: reset

import org.apache.commons.math3.util.MathUtils; //导入方法依赖的package包/类
/** Reset the instance as if built from a line and an angle.
 * @param p point belonging to the line
 * @param alpha angle of the line with respect to abscissa axis
 */
public void reset(final Vector2D p, final double alpha) {
    unlinkReverse();
    this.angle   = MathUtils.normalizeAngle(alpha, FastMath.PI);
    cos          = FastMath.cos(this.angle);
    sin          = FastMath.sin(this.angle);
    originOffset = MathArrays.linearCombination(cos, p.getY(), -sin, p.getX());
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:12,代码来源:Line.java

示例5: setAngle

import org.apache.commons.math3.util.MathUtils; //导入方法依赖的package包/类
/** Set the angle of the line.
 * @param angle new angle of the line with respect to the abscissa axis
 */
public void setAngle(final double angle) {
    unlinkReverse();
    this.angle = MathUtils.normalizeAngle(angle, FastMath.PI);
    cos        = FastMath.cos(this.angle);
    sin        = FastMath.sin(this.angle);
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:10,代码来源:Line.java

示例6: createSplitPart

import org.apache.commons.math3.util.MathUtils; //导入方法依赖的package包/类
/** Create a split part.
 * <p>
 * As per construction, the list of limit angles is known to have
 * an even number of entries, with start angles at even indices and
 * end angles at odd indices.
 * </p>
 * @param limits limit angles of the split part
 * @return split part (may be null)
 */
private ArcsSet createSplitPart(final List<Double> limits) {
    if (limits.isEmpty()) {
        return null;
    } else {

        // collapse close limit angles
        for (int i = 0; i < limits.size(); ++i) {
            final int    j  = (i + 1) % limits.size();
            final double lA = limits.get(i);
            final double lB = MathUtils.normalizeAngle(limits.get(j), lA);
            if (FastMath.abs(lB - lA) <= getTolerance()) {
                // the two limits are too close to each other, we remove both of them
                if (j > 0) {
                    // regular case, the two entries are consecutive ones
                    limits.remove(j);
                    limits.remove(i);
                    i = i - 1;
                } else {
                    // special case, i the the last entry and j is the first entry
                    // we have wrapped around list end
                    final double lEnd   = limits.remove(limits.size() - 1);
                    final double lStart = limits.remove(0);
                    if (limits.isEmpty()) {
                        // the ends were the only limits, is it a full circle or an empty circle?
                        if (lEnd - lStart > FastMath.PI) {
                            // it was full circle
                            return new ArcsSet(new BSPTree<Sphere1D>(Boolean.TRUE), getTolerance());
                        } else {
                            // it was an empty circle
                            return null;
                        }
                    } else {
                        // we have removed the first interval start, so our list
                        // currently starts with an interval end, which is wrong
                        // we need to move this interval end to the end of the list
                        limits.add(limits.remove(0) + MathUtils.TWO_PI);
                    }
                }
            }
        }

        // build the tree by adding all angular sectors
        BSPTree<Sphere1D> tree = new BSPTree<Sphere1D>(Boolean.FALSE);
        for (int i = 0; i < limits.size() - 1; i += 2) {
            addArcLimit(tree, limits.get(i),     true);
            addArcLimit(tree, limits.get(i + 1), false);
        }

        if (tree.getCut() == null) {
            // we did not insert anything
            return null;
        }

        return new ArcsSet(tree, getTolerance());

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

示例7: split

import org.apache.commons.math3.util.MathUtils; //导入方法依赖的package包/类
/** Split the edge.
 * <p>
 * Once split, this edge is not referenced anymore by the vertices,
 * it is replaced by the two or three sub-edges and intermediate splitting
 * vertices are introduced to connect these sub-edges together.
 * </p>
 * @param splitCircle circle splitting the edge in several parts
 * @param outsideList list where to put parts that are outside of the split circle
 * @param insideList list where to put parts that are inside the split circle
 */
void split(final Circle splitCircle,
                   final List<Edge> outsideList, final List<Edge> insideList) {

    // get the inside arc, synchronizing its phase with the edge itself
    final double edgeStart        = circle.getPhase(start.getLocation().getVector());
    final Arc    arc              = circle.getInsideArc(splitCircle);
    final double arcRelativeStart = MathUtils.normalizeAngle(arc.getInf(), edgeStart + FastMath.PI) - edgeStart;
    final double arcRelativeEnd   = arcRelativeStart + arc.getSize();
    final double unwrappedEnd     = arcRelativeEnd - MathUtils.TWO_PI;

    // build the sub-edges
    final double tolerance = circle.getTolerance();
    Vertex previousVertex = start;
    if (unwrappedEnd >= length - tolerance) {

        // the edge is entirely contained inside the circle
        // we don't split anything
        insideList.add(this);

    } else {

        // there are at least some parts of the edge that should be outside
        // (even is they are later be filtered out as being too small)
        double alreadyManagedLength = 0;
        if (unwrappedEnd >= 0) {
            // the start of the edge is inside the circle
            previousVertex = addSubEdge(previousVertex,
                                        new Vertex(new S2Point(circle.getPointAt(edgeStart + unwrappedEnd))),
                                        unwrappedEnd, insideList, splitCircle);
            alreadyManagedLength = unwrappedEnd;
        }

        if (arcRelativeStart >= length - tolerance) {
            // the edge ends while still outside of the circle
            if (unwrappedEnd >= 0) {
                previousVertex = addSubEdge(previousVertex, end,
                                            length - alreadyManagedLength, outsideList, splitCircle);
            } else {
                // the edge is entirely outside of the circle
                // we don't split anything
                outsideList.add(this);
            }
        } else {
            // the edge is long enough to enter inside the circle
            previousVertex = addSubEdge(previousVertex,
                                        new Vertex(new S2Point(circle.getPointAt(edgeStart + arcRelativeStart))),
                                        arcRelativeStart - alreadyManagedLength, outsideList, splitCircle);
            alreadyManagedLength = arcRelativeStart;

            if (arcRelativeEnd >= length - tolerance) {
                // the edge ends while still inside of the circle
                previousVertex = addSubEdge(previousVertex, end,
                                            length - alreadyManagedLength, insideList, splitCircle);
            } else {
                // the edge is long enough to exit outside of the circle
                previousVertex = addSubEdge(previousVertex,
                                            new Vertex(new S2Point(circle.getPointAt(edgeStart + arcRelativeStart))),
                                            arcRelativeStart - alreadyManagedLength, insideList, splitCircle);
                alreadyManagedLength = arcRelativeStart;
                previousVertex = addSubEdge(previousVertex, end,
                                            length - alreadyManagedLength, outsideList, splitCircle);
            }
        }

    }

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

示例8: getAngle

import org.apache.commons.math3.util.MathUtils; //导入方法依赖的package包/类
/** Get the angle of the line.
 * @return the angle of the line with respect to the abscissa axis
 */
public double getAngle() {
    return MathUtils.normalizeAngle(angle, FastMath.PI);
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:7,代码来源:Line.java

示例9: S1Point

import org.apache.commons.math3.util.MathUtils; //导入方法依赖的package包/类
/** Simple constructor.
 * Build a vector from its coordinates
 * @param alpha azimuthal angle \( \alpha \)
 * @see #getAlpha()
 */
public S1Point(final double alpha) {
    this(MathUtils.normalizeAngle(alpha, FastMath.PI),
         new Vector2D(FastMath.cos(alpha), FastMath.sin(alpha)));
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:10,代码来源:S1Point.java


注:本文中的org.apache.commons.math3.util.MathUtils.normalizeAngle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。