MathF.Atan2(Single, Single) 方法

定义

返回正切值为两个指定数字的商的角度。Returns the angle whose tangent is the quotient of two specified numbers.

public:
 static float Atan2(float y, float x);
public static float Atan2 (float y, float x);
static member Atan2 : single * single -> single
Public Shared Function Atan2 (y As Single, x As Single) As Single

参数

y
Single

点的 y 坐标。The y coordinate of a point.

x
Single

点的 x 坐标。The x coordinate of a point.

返回

角度 θ,以弧度为单位,满足 -π ≤ θ ≤ π,且 tan(θ) = y / x,其中 (x, y) 是笛卡儿平面中的点。An angle, θ, measured in radians, such that -π ≤ θ ≤ π, and tan(θ) = y / x, where (x, y) is a point in the Cartesian plane. 请看下面:Observe the following: - 由于 (x, y) 在第 1 象限,因此 0 < θ < π/2。- For (x, y) in quadrant 1, 0 < θ < π/2.

- 由于 (x, y) 在第 2 象限,因此 π/2 < θ ≤ π。- For (x, y) in quadrant 2, π/2 < θ ≤ π.

- 由于 (x, y) 在第 3 象限,因此 -π < θ < -π/2。- For (x, y) in quadrant 3, -π < θ < -π/2.

- 由于 (x, y) 在第 4 象限,因此 -π/2 < θ < 0。- For (x, y) in quadrant 4, -π/2 < θ < 0.

如果点在象限的边界上,则返回值如下:For points on the boundaries of the quadrants, the return value is the following: - 如果 y 为 0 并且 x 不为负值,则 θ = 0。- If y is 0 and x is not negative, θ = 0.

- 如果 y 为 0 并且 x 为负值,则 θ = π。- If y is 0 and x is negative, θ = π.

- 如果 y 为正值并且 x 为 0,则 θ = π/2。- If y is positive and x is 0, θ = π/2.

- 如果 y 为负值并且 x 为 0,则 θ = -π/2。- If y is negative and x is 0, θ = -π/2.

- 如果 y 为 0 并且 x 为 0,则 θ = 0。- If y is 0 and x is 0, θ = 0.

如果 xyNaN,或者如果 xyPositiveInfinityNegativeInfinity,则该方法返回 NaNIf x or y is NaN, or if x and y are either PositiveInfinity or NegativeInfinity, the method returns NaN.

注解

返回值是由 x 轴和向量 (0, 0) 开始并在点 (x, y) 处终止的笛卡尔平面中的角度。The return value is the angle in the Cartesian plane formed by the x-axis, and a vector starting from the origin, (0,0), and terminating at the point, (x,y).

适用于