我正在尝试将笛卡尔 3d 坐标系中的一个点转换为球形 3d 系统。
这是我到目前为止得到的:
radialDistance3D (x,y,z) = sqrt (x*2 + y*y + z*z)
cartesian3DToPolar3D (x,y,z) = (r,alpha, beta)
where r = radialDistance3D (x,y,z)
alpha = acos(z/r)
beta = atan2(y,x)
Ghci 加载代码但是当我尝试执行它时
Cartesian3DToPolar3D (1.0,2.0,3.0)
我得到:
<interactive>:1:0:
No instance for (RealFloat (t, t))
arising from a use of `cartesian3DToPolar3D'
at <interactive>:1:0-33
Possible fix: add an instance declaration for (RealFloat (t, t))
In the expression: cartesian3DToPolar3D (1.0, 2.0, 3.0)
In the definition of `it':
it = cartesian3DToPolar3D (1.0, 2.0, 3.0)
这没有帮助。到底是怎么回事?
转换公式来自http://en.wikipedia.org/wiki/Spherical_coordinate_system#Cartesian_coordinates