首页 > 编程知识 正文

java在线编程,java编程技巧

时间:2023-05-04 15:54:36 阅读:258229 作者:2012




第342条:将直角坐标化为极坐标


342 Converting Rectangular Coordinates to Polar Coordinates

 342 将直角坐标转换成极坐标

 In the rectangular coordinate system, thecoordinates (x, y) locate a point x units along the x-axis and y units alongthe y-axis. In the polar coordinate system, the coordinates (r, () locate apoint r units from the origin and at an angle ( measured from a reference line.If you have the (x, y) rectangular coordinates and would like to convert themto polar coordinates (r, (), you can use the following equations: 

在直角坐标系统中,坐标(x,y)在平面上确定了这样一个点,它沿 x 轴的分量是 x 单元,而 y 轴的分量是 y 单元. 而在极坐标系统中,坐标(ro,thita)在平面上确定了这样一个点,它离原点的 距离是 ro 单元,而与参考线的夹角为 thita 弧度. 如果你已知直角坐标系统中坐标(x,y),而想把 它们转换成极坐标(ro,thita),则你可使用以下两个方程式: 

ro = sqrt(x2 + y2)                                            - 6 - 

thita = arctan(y/x)

To implement these equations in Java, use statements similar to the following:

在 Java 中要实现这两个方程,可使用以下这样的语句:

 float x = 10F, y = 20F; 

 float r = (float)Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2)); 

 float theta = (float)Math.atan(y/x); 

 System.out.println(r + “, “ + theta); 

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。