本文整理匯總了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);
}
示例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);
}
示例3: getAngle
import org.apache.commons.math3.util.FastMath; //導入方法依賴的package包/類
/** Get the angle of the rotation.
* @return angle of the rotation (between 0 and π)
* @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);
}
示例4: value
import org.apache.commons.math3.util.FastMath; //導入方法依賴的package包/類
/** {@inheritDoc} */
public double value(double x) {
return FastMath.asin(x);
}
示例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);
}
示例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);
}
示例7: getDelta
import org.apache.commons.math3.util.FastMath; //導入方法依賴的package包/類
/** Get the elevation of the vector.
* @return elevation (δ) of the vector, between -π/2 and +π/2
* @see #Vector3D(double, double)
*/
public double getDelta() {
return FastMath.asin(z / getNorm());
}