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


Java BigFraction.doubleValue方法代码示例

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


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

示例1: ballOnSupport

import org.apache.commons.math3.fraction.BigFraction; //导入方法依赖的package包/类
/** {@inheritDoc} */
public EnclosingBall<Euclidean2D, Vector2D> ballOnSupport(final List<Vector2D> support) {

    if (support.size() < 1) {
        return new EnclosingBall<Euclidean2D, Vector2D>(Vector2D.ZERO, Double.NEGATIVE_INFINITY);
    } else {
        final Vector2D vA = support.get(0);
        if (support.size() < 2) {
            return new EnclosingBall<Euclidean2D, Vector2D>(vA, 0, vA);
        } else {
            final Vector2D vB = support.get(1);
            if (support.size() < 3) {
                return new EnclosingBall<Euclidean2D, Vector2D>(new Vector2D(0.5, vA, 0.5, vB),
                                                                0.5 * vA.distance(vB),
                                                                vA, vB);
            } else {
                final Vector2D vC = support.get(2);
                // a disk is 2D can be defined as:
                // (1)   (x - x_0)^2 + (y - y_0)^2 = r^2
                // which can be written:
                // (2)   (x^2 + y^2) - 2 x_0 x - 2 y_0 y + (x_0^2 + y_0^2 - r^2) = 0
                // or simply:
                // (3)   (x^2 + y^2) + a x + b y + c = 0
                // with disk center coordinates -a/2, -b/2
                // If the disk exists, a, b and c are a non-zero solution to
                // [ (x^2  + y^2 )   x    y   1 ]   [ 1 ]   [ 0 ]
                // [ (xA^2 + yA^2)   xA   yA  1 ]   [ a ]   [ 0 ]
                // [ (xB^2 + yB^2)   xB   yB  1 ] * [ b ] = [ 0 ]
                // [ (xC^2 + yC^2)   xC   yC  1 ]   [ c ]   [ 0 ]
                // So the determinant of the matrix is zero. Computing this determinant
                // by expanding it using the minors m_ij of first row leads to
                // (4)   m_11 (x^2 + y^2) - m_12 x + m_13 y - m_14 = 0
                // So by identifying equations (2) and (4) we get the coordinates
                // of center as:
                //      x_0 = +m_12 / (2 m_11)
                //      y_0 = -m_13 / (2 m_11)
                // Note that the minors m_11, m_12 and m_13 all have the last column
                // filled with 1.0, hence simplifying the computation
                final BigFraction[] c2 = new BigFraction[] {
                    new BigFraction(vA.getX()), new BigFraction(vB.getX()), new BigFraction(vC.getX())
                };
                final BigFraction[] c3 = new BigFraction[] {
                    new BigFraction(vA.getY()), new BigFraction(vB.getY()), new BigFraction(vC.getY())
                };
                final BigFraction[] c1 = new BigFraction[] {
                    c2[0].multiply(c2[0]).add(c3[0].multiply(c3[0])),
                    c2[1].multiply(c2[1]).add(c3[1].multiply(c3[1])),
                    c2[2].multiply(c2[2]).add(c3[2].multiply(c3[2]))
                };
                final BigFraction twoM11  = minor(c2, c3).multiply(2);
                final BigFraction m12     = minor(c1, c3);
                final BigFraction m13     = minor(c1, c2);
                final BigFraction centerX = m12.divide(twoM11);
                final BigFraction centerY = m13.divide(twoM11).negate();
                final BigFraction dx      = c2[0].subtract(centerX);
                final BigFraction dy      = c3[0].subtract(centerY);
                final BigFraction r2      = dx.multiply(dx).add(dy.multiply(dy));
                return new EnclosingBall<Euclidean2D, Vector2D>(new Vector2D(centerX.doubleValue(),
                                                                             centerY.doubleValue()),
                                                                FastMath.sqrt(r2.doubleValue()),
                                                                vA, vB, vC);
            }
        }
    }
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:66,代码来源:DiskGenerator.java

示例2: visit

import org.apache.commons.math3.fraction.BigFraction; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
public void visit(int row, int column, BigFraction value) {
    data[row][column] = value.doubleValue();
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:6,代码来源:MatrixUtils.java

示例3: getBarWidth

import org.apache.commons.math3.fraction.BigFraction; //导入方法依赖的package包/类
private double getBarWidth(BigFraction numberOfVotes) {
    return numberOfVotes.doubleValue() * getWidthPerVote();
}
 
开发者ID:BGehrels,项目名称:singleTransferableVoteElections-web,代码行数:4,代码来源:VotesForCandidate.java


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