欢迎访问悦橙教程(wld5.com),关注java教程。悦橙教程  java问答|  每日更新
页面导航 : > > 文章正文

坐标转换:Polar to Cartesian,polarcartesian,def c2p put

来源: javaer 分享于  点击 15020 次 点评:245

坐标转换:Polar to Cartesian,polarcartesian,def c2p put


def c2p  puts "Enter x"  x=gets.chomp  x=x.to_f  puts "Enter y"  y=gets.chomp  y=y.to_f  r=Math.sqrt((x**2)+(y**2))  t=Math.atan(y/x)  deg=(180*t)/3.14  puts "The coordinate in polar system is ("+r.to_s+","+deg.to_s+")"enddef p2c  puts "Enter r"  r=gets.chomp  r=r.to_f  puts "Enter angle in degree"  t=gets.chomp  t=t.to_f  x=r*Math.cos((t*3.14)/180)  y=r*Math.sin((t*3.14)/180)  puts "The coordinate in the cartesian system is ("+x.to_s+","+y.to_s+")"end//该片段来自于http://byrx.net
相关栏目:

用户点评