本文整理了Java中java.lang.Math.atan2()
方法的一些代码示例,展示了Math.atan2()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Math.atan2()
方法的具体详情如下:
包路径:java.lang.Math
类名称:Math
方法名:atan2
[英]Returns the closest double approximation of the arc tangent of y/x within the range [-pi..pi]. This is the angle of the polar representation of the rectangular coordinates (x,y). The returned result is within 2 ulps (units in the last place) of the real result.
Special cases:
代码示例来源:origin: libgdx/libgdx
/** @return the angle in degrees of this vector (point) relative to the x-axis. Angles are towards the positive y-axis
* (typically counter-clockwise) and between 0 and 360. */
public float angle () {
float angle = (float)Math.atan2(y, x) * MathUtils.radiansToDegrees;
if (angle < 0) angle += 360;
return angle;
}
代码示例来源:origin: libgdx/libgdx
/** @return the angle in radians of this vector (point) relative to the x-axis. Angles are towards the positive y-axis.
* (typically counter-clockwise) */
public float angleRad () {
return (float)Math.atan2(y, x);
}
代码示例来源:origin: libgdx/libgdx
/** @return the angle in degrees of this vector (point) relative to the x-axis. Angles are towards the positive y-axis
* (typically counter-clockwise) and between 0 and 360. */
public float angle () {
float angle = (float)Math.atan2(y, x) * MathUtils.radiansToDegrees;
if (angle < 0) angle += 360;
return angle;
}
代码示例来源:origin: libgdx/libgdx
/** @return the angle in radians of this vector (point) relative to the x-axis. Angles are towards the positive y-axis.
* (typically counter-clockwise) */
public float angleRad () {
return (float)Math.atan2(y, x);
}
代码示例来源:origin: libgdx/libgdx
public float getRotation () {
return (float)Math.atan2(vals[SIN], vals[COS]);
}
/** @return A vector 2 pointing to where the body is facing */
代码示例来源:origin: libgdx/libgdx
public float getRotation () {
return (float)Math.atan2(vals[SIN], vals[COS]);
}
/** @return A vector 2 pointing to where the body is facing */
代码示例来源:origin: libgdx/libgdx
public float getRotationRad () {
return (float)Math.atan2(val[M10], val[M00]);
}
代码示例来源:origin: libgdx/libgdx
public float getRotationRad () {
return (float)Math.atan2(val[M10], val[M00]);
}
代码示例来源:origin: libgdx/libgdx
public float getRotation () {
return MathUtils.radiansToDegrees * (float)Math.atan2(val[M10], val[M00]);
}
代码示例来源:origin: libgdx/libgdx
public float getRotation () {
return MathUtils.radiansToDegrees * (float)Math.atan2(val[M10], val[M00]);
}
代码示例来源:origin: libgdx/libgdx
public static double atan2(double y, double x) {
return Math.atan2(y,x);
}
代码示例来源:origin: stackoverflow.com
var rad = function(x) {
return x * Math.PI / 180;
};
var getDistance = function(p1, p2) {
var R = 6378137; // Earth’s mean radius in meter
var dLat = rad(p2.lat() - p1.lat());
var dLong = rad(p2.lng() - p1.lng());
var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
Math.cos(rad(p1.lat())) * Math.cos(rad(p2.lat())) *
Math.sin(dLong / 2) * Math.sin(dLong / 2);
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
var d = R * c;
return d; // returns the distance in meter
};
代码示例来源:origin: prestodb/presto
public double distance(double latitude2, double longitude2)
{
double radianLatitude2 = toRadians(latitude2);
double sin2 = sin(radianLatitude2);
double cos2 = cos(radianLatitude2);
double deltaLongitude = radianLongitude - toRadians(longitude2);
double cosDeltaLongitude = cos(deltaLongitude);
double t1 = cos2 * sin(deltaLongitude);
double t2 = cosLatitude * sin2 - sinLatitude * cos2 * cosDeltaLongitude;
double t3 = sinLatitude * sin2 + cosLatitude * cos2 * cosDeltaLongitude;
return atan2(sqrt(t1 * t1 + t2 * t2), t3) * EARTH_RADIUS_KM;
}
}
代码示例来源:origin: apache/incubator-druid
@Override
protected ExprEval eval(double y, double x)
{
return ExprEval.of(Math.atan2(y, x));
}
}
代码示例来源:origin: libgdx/libgdx
/** @return the angle in degrees of this vector (point) relative to the given vector. Angles are towards the positive y-axis
* (typically counter-clockwise.) between -180 and +180 */
public float angle (Vector2 reference) {
return (float)Math.atan2(crs(reference), dot(reference)) * MathUtils.radiansToDegrees;
}
代码示例来源:origin: libgdx/libgdx
/** @return the angle in radians of this vector (point) relative to the given vector. Angles are towards the positive y-axis.
* (typically counter-clockwise.) */
public float angleRad (Vector2 reference) {
return (float)Math.atan2(crs(reference), dot(reference));
}
代码示例来源:origin: libgdx/libgdx
/** @return the angle in radians of this vector (point) relative to the given vector. Angles are towards the positive y-axis.
* (typically counter-clockwise.) */
public float angleRad (Vector2 reference) {
return (float)Math.atan2(crs(reference), dot(reference));
}
代码示例来源:origin: libgdx/libgdx
/** @return the angle in degrees of this vector (point) relative to the given vector. Angles are towards the positive y-axis
* (typically counter-clockwise.) between -180 and +180 */
public float angle (Vector2 reference) {
return (float)Math.atan2(crs(reference), dot(reference)) * MathUtils.radiansToDegrees;
}
代码示例来源:origin: prestodb/presto
@Description("arc tangent of given fraction")
@ScalarFunction
@SqlType(StandardTypes.DOUBLE)
public static double atan2(@SqlType(StandardTypes.DOUBLE) double num1, @SqlType(StandardTypes.DOUBLE) double num2)
{
return Math.atan2(num1, num2);
}
代码示例来源:origin: prestodb/presto
@Test
public void testAtan2()
{
for (double doubleValue : DOUBLE_VALUES) {
assertFunction("atan2(" + doubleValue + ", " + doubleValue + ")", DOUBLE, Math.atan2(doubleValue, doubleValue));
assertFunction("atan2(REAL '" + (float) doubleValue + "', REAL '" + (float) doubleValue + "')", DOUBLE, Math.atan2((float) doubleValue, (float) doubleValue));
}
assertFunction("atan2(NULL, NULL)", DOUBLE, null);
assertFunction("atan2(1.0E0, NULL)", DOUBLE, null);
assertFunction("atan2(NULL, 1.0E0)", DOUBLE, null);
}
内容来源于网络,如有侵权,请联系作者删除!