极角的定义及其代码实现

极角的定义

在这里插入图片描述
如图所示,极坐标系中,每一个点M,都可以用其距离原点O的距离ρ\rhoρ和OM与x轴的夹角θ\thetaθ唯一确定。M的极坐标为(ρ,θ)(\rho,\theta)(ρ,θ),其中θ\thetaθ为极角。

极角的计算

设M点在直角坐标系中的坐标为(x,y)(x,y)(x,y),原点O的坐标为(0,0)(0,0)(0,0),则与极坐标存在如下等式关系:
{ρ=x2+y2tan⁡(θ)=yx(x≠0)\begin{cases} \rho = x^2 + y ^ 2 \\ \tan(\theta) = \frac y x (x \neq 0)\end{cases}{ρ=x2+y2tan(θ)=xy(x=0){x=ρcos⁡(θ)y=ρsin⁡(θ)\begin{cases} x = \rho \cos(\theta) \\ y = \rho \sin(\theta) \end{cases}{x=ρcos(θ)y=ρsin(θ)
所以,极角θ=arctan⁡(yx)\theta=\arctan(\frac y x)θ=arctan(xy)

代码实现

使用java.lang.Math的atan2函数,对于点M(x,y)(x,y)(x,y),其与原点O(0,0)(0,0)(0,0)的极角θ=Math.atan2(y,x)\theta = Math.atan2(y, x)θ=Math.atan2(y,x)

public static double atan2(double y, double x)

如果O的坐标为(x0,y0)(x_0,y_0)(x0,y0),点M(x,y)(x,y)(x,y)与O的极角为θ=Math.atan2(y−y0,x−x0)\theta = Math.atan2(y-y_0, x-x_0)θ=Math.atan2(yy0,xx0)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值