本文整理汇总了Java中org.apache.commons.math3.util.FastMath.acos方法的典型用法代码示例。如果您正苦于以下问题:Java FastMath.acos方法的具体用法?Java FastMath.acos怎么用?Java FastMath.acos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.math3.util.FastMath
的用法示例。
在下文中一共展示了FastMath.acos方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: gcpSlantRangeAndIncidenceAngleForComplex
import org.apache.commons.math3.util.FastMath; //导入方法依赖的package包/类
/**
* ( Parameters have the names used in radarsat2 metadata )
*
* @param complex
* @param slantRangenearEdge
* @param samplePixelSpacing
* @param ngrd
* @param nsam
* @return
*/
public static double gcpSlantRangeAndIncidenceAngleForComplex(double slantRangeNearEdge,double sizeXPixel,double samplePixelSpacing,double xPix,double hsat,double earthRad,String timeOrdering){
double slantAndIA=0;
//calculate the slant range for the gpc
double slantRangeFarGpc=slantRangeNearEdge+sizeXPixel*samplePixelSpacing;
double slntRangePixel=0;
if(timeOrdering.equalsIgnoreCase("Increasing")){
//calculate the gnd range for the gpc
slntRangePixel=slantRangeFarGpc+xPix*samplePixelSpacing;
}else{
slntRangePixel=slantRangeFarGpc-xPix*samplePixelSpacing;
}
//incidence angle
slantAndIA=FastMath.acos(hsat*(1+hsat/(2*earthRad))/slntRangePixel-slntRangePixel/(2*earthRad));
return slantAndIA;
}
示例2: gcpIncidenceAngleForGRD
import org.apache.commons.math3.util.FastMath; //导入方法依赖的package包/类
/**
* ( Parameters have the names used in radarsat2 metadata )
*
* @param complex
* @param gndRange
* @param samplePixelSpacing
* @param ngrd
* @param nsam
* @return
*/
public static double gcpIncidenceAngleForGRD(double slntRangeInNearRange,double sizeXPixel,double samplePixelSpacing,double xPix,double hsat,double earthRad,String timeOrdering){
double srAndIA=0;
//convert slant range into grnd range
double gndRangeAtNearRange=earthRad*FastMath.acos(1-(slntRangeInNearRange*slntRangeInNearRange-hsat*hsat)/(2*earthRad*(earthRad+hsat)) );
double gndRangePixel=0;
double gndRangeAtFarRange=gndRangeAtNearRange+sizeXPixel*samplePixelSpacing;
if(timeOrdering.equalsIgnoreCase("Increasing")){
//calculate the gnd range for the gpc
gndRangePixel=gndRangeAtNearRange+xPix*samplePixelSpacing;
}else{
gndRangePixel=gndRangeAtFarRange-xPix*samplePixelSpacing;
}
//slant range
double finalSlantRange=FastMath.sqrt(hsat*hsat + (2*earthRad*(earthRad+hsat))*(1-FastMath.cos(gndRangePixel/earthRad)));
//incidence angle
srAndIA=FastMath.acos((hsat*(1+hsat/(2*earthRad))/finalSlantRange) - (finalSlantRange/(2*earthRad)));
//double conv=srAndIA*180/Math.PI;
//System.out.println(conv);
return srAndIA;
}
示例3: 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);
}
示例4: 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);
}
示例5: SphericalCoordinates
import org.apache.commons.math3.util.FastMath; //导入方法依赖的package包/类
/** Build a spherical coordinates transformer from Cartesian coordinates.
* @param v Cartesian coordinates
*/
public SphericalCoordinates(final Vector3D v) {
// Cartesian coordinates
this.v = v;
// remaining spherical coordinates
this.r = v.getNorm();
this.theta = v.getAlpha();
this.phi = FastMath.acos(v.getZ() / r);
}
示例6: 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);
}
示例7: value
import org.apache.commons.math3.util.FastMath; //导入方法依赖的package包/类
/** {@inheritDoc} */
public double value(double x) {
return FastMath.acos(x);
}
示例8: acos
import org.apache.commons.math3.util.FastMath; //导入方法依赖的package包/类
/** {@inheritDoc} */
public SparseGradient acos() {
return new SparseGradient(FastMath.acos(value), -1.0 / FastMath.sqrt(1 - value * value), derivatives);
}
示例9: acos
import org.apache.commons.math3.util.FastMath; //导入方法依赖的package包/类
/** Compute arc cosine 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 cosine the result array <em>cannot</em> be the input
* array)
* @param resultOffset offset of the result in its array
*/
public void acos(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.acos(x);
if (order > 0) {
// the nth order derivative of acos has the form:
// dn(acos(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);
}
示例10: distanceRad
import org.apache.commons.math3.util.FastMath; //导入方法依赖的package包/类
/**
*
* @param lon1 in radians
* @param lat1 in radians
* @param lon2 in radians
* @param lat2 in radians
* @return calculate the distance between 2 points
*/
public static double distanceRad(double lonRad1, double latRad1, double lonRad2, double latRad2){
double dlon = FastMath.abs(lonRad1 - lonRad2);
double p=FastMath.acos(FastMath.sin(latRad2)*FastMath.sin(latRad1)+FastMath.cos(latRad2) * FastMath.cos(latRad1) * FastMath.cos(dlon));
double d = R_HEART * p ;
return d;
}