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


Java FastMath.asin方法代码示例

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


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

示例1: angle

import org.apache.commons.math3.util.FastMath; //导入方法依赖的package包/类
/** Compute the angular separation between two vectors.
 * <p>This method computes the angular separation between two
 * vectors using the dot product for well separated vectors and the
 * cross product for almost aligned vectors. This allows to have a
 * good accuracy in all cases, even for vectors very close to each
 * other.</p>
 * @param v1 first vector
 * @param v2 second vector
 * @return angular separation between v1 and v2
 * @exception MathArithmeticException if either vector has a null norm
 */
public static double angle(Vector3D v1, Vector3D v2) throws MathArithmeticException {

    double normProduct = v1.getNorm() * v2.getNorm();
    if (normProduct == 0) {
        throw new MathArithmeticException(LocalizedFormats.ZERO_NORM);
    }

    double dot = v1.dotProduct(v2);
    double threshold = normProduct * 0.9999;
    if ((dot < -threshold) || (dot > threshold)) {
        // the vectors are almost aligned, compute using the sine
        Vector3D v3 = crossProduct(v1, v2);
        if (dot >= 0) {
            return FastMath.asin(v3.getNorm() / normProduct);
        }
        return FastMath.PI - FastMath.asin(v3.getNorm() / normProduct);
    }

    // the vectors are sufficiently separated to use the cosine
    return FastMath.acos(dot / normProduct);

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

示例2: angle

import org.apache.commons.math3.util.FastMath; //导入方法依赖的package包/类
/** Compute the angular separation between two vectors.
 * <p>This method computes the angular separation between two
 * vectors using the dot product for well separated vectors and the
 * cross product for almost aligned vectors. This allows to have a
 * good accuracy in all cases, even for vectors very close to each
 * other.</p>
 * @param v1 first vector
 * @param v2 second vector
 * @return angular separation between v1 and v2
 * @exception MathArithmeticException if either vector has a null norm
 */
public static double angle(Vector2D v1, Vector2D v2) throws MathArithmeticException {

    double normProduct = v1.getNorm() * v2.getNorm();
    if (normProduct == 0) {
        throw new MathArithmeticException(LocalizedFormats.ZERO_NORM);
    }

    double dot = v1.dotProduct(v2);
    double threshold = normProduct * 0.9999;
    if ((dot < -threshold) || (dot > threshold)) {
        // the vectors are almost aligned, compute using the sine
        final double n = FastMath.abs(MathArrays.linearCombination(v1.x, v2.y, -v1.y, v2.x));
        if (dot >= 0) {
            return FastMath.asin(n / normProduct);
        }
        return FastMath.PI - FastMath.asin(n / normProduct);
    }

    // the vectors are sufficiently separated to use the cosine
    return FastMath.acos(dot / normProduct);

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

示例3: getAngle

import org.apache.commons.math3.util.FastMath; //导入方法依赖的package包/类
/** Get the angle of the rotation.
 * @return angle of the rotation (between 0 and &pi;)
 * @see #Rotation(Vector3D, double)
 */
public double getAngle() {
  if ((q0 < -0.1) || (q0 > 0.1)) {
    return 2 * FastMath.asin(FastMath.sqrt(q1 * q1 + q2 * q2 + q3 * q3));
  } else if (q0 < 0) {
    return 2 * FastMath.acos(-q0);
  }
  return 2 * FastMath.acos(q0);
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:13,代码来源:Rotation.java

示例4: value

import org.apache.commons.math3.util.FastMath; //导入方法依赖的package包/类
/** {@inheritDoc} */
public double value(double x) {
    return FastMath.asin(x);
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:5,代码来源:Asin.java

示例5: asin

import org.apache.commons.math3.util.FastMath; //导入方法依赖的package包/类
/** {@inheritDoc} */
public SparseGradient asin() {
    return new SparseGradient(FastMath.asin(value), 1.0 / FastMath.sqrt(1 - value * value), derivatives);
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:5,代码来源:SparseGradient.java

示例6: asin

import org.apache.commons.math3.util.FastMath; //导入方法依赖的package包/类
/** Compute arc sine of a derivative structure.
 * @param operand array holding the operand
 * @param operandOffset offset of the operand in its array
 * @param result array where result must be stored (for
 * arc sine the result array <em>cannot</em> be the input
 * array)
 * @param resultOffset offset of the result in its array
 */
public void asin(final double[] operand, final int operandOffset,
                final double[] result, final int resultOffset) {

    // create the function value and derivatives
    double[] function = new double[1 + order];
    final double x = operand[operandOffset];
    function[0] = FastMath.asin(x);
    if (order > 0) {
        // the nth order derivative of asin has the form:
        // dn(asin(x)/dxn = P_n(x) / [1 - x^2]^((2n-1)/2)
        // where P_n(x) is a degree n-1 polynomial with same parity as n-1
        // P_1(x) = 1, P_2(x) = x, P_3(x) = 2x^2 + 1 ...
        // the general recurrence relation for P_n is:
        // P_n(x) = (1-x^2) P_(n-1)'(x) + (2n-3) x P_(n-1)(x)
        // as per polynomial parity, we can store coefficients of both P_(n-1) and P_n in the same array
        final double[] p = new double[order];
        p[0] = 1;
        final double x2    = x * x;
        final double f     = 1.0 / (1 - x2);
        double coeff = FastMath.sqrt(f);
        function[1] = coeff * p[0];
        for (int n = 2; n <= order; ++n) {

            // update and evaluate polynomial P_n(x)
            double v = 0;
            p[n - 1] = (n - 1) * p[n - 2];
            for (int k = n - 1; k >= 0; k -= 2) {
                v = v * x2 + p[k];
                if (k > 2) {
                    p[k - 2] = (k - 1) * p[k - 1] + (2 * n - k) * p[k - 3];
                } else if (k == 2) {
                    p[0] = p[1];
                }
            }
            if ((n & 0x1) == 0) {
                v *= x;
            }

            coeff *= f;
            function[n] = coeff * v;

        }
    }

    // apply function composition
    compose(operand, operandOffset, function, result, resultOffset);

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

示例7: getDelta

import org.apache.commons.math3.util.FastMath; //导入方法依赖的package包/类
/** Get the elevation of the vector.
 * @return elevation (&delta;) of the vector, between -&pi;/2 and +&pi;/2
 * @see #Vector3D(double, double)
 */
public double getDelta() {
    return FastMath.asin(z / getNorm());
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:8,代码来源:Vector3D.java


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