Three.js - 具有球坐标的弯曲平面

时间:2014-11-02 12:22:10

标签: three.js geometry coordinates

我尝试使用球面坐标弯曲平面网格。我在维基百科上的令牌公式,它几乎工作! 但是一些顶点定位在同一个地方。 网格平面位于0,0,0,您可以在此处观察结果:

之前:http://hpics.li/78c0871

之后:http://hpics.li/19ada1a

这是我的代码:

@radius = 4
@oPhi = 0
@oTheta = 0
projection : (vertice) ->
    p = Math.sqrt(vertice.x ** 2 + vertice.y ** 2)
    c = Math.asin(p/@radius)
    phi = Math.asin(Math.cos(c) * Math.sin(@oPhi) + (vertice.y * Math.sin(c) * Math.cos(@oPhi) / p))
    theta = @oTheta + Math.atan((vertice.x * Math.sin(c)) / (p * Math.cos(@oPhi) * Math.cos(c) - vertice.y * Math.sin(@oPhi) * Math.sin(c)))
    vertice.x = @radius * Math.sin(phi) * Math.cos(theta)
    vertice.z = @radius * Math.sin(phi) * Math.sin(theta)
    vertice.y = @radius * Math.cos(phi) 

感谢您的帮助!

1 个答案:

答案 0 :(得分:0)

很抱歉,但公式涉及到正投影,您可以在此处看到: http://fr.wikipedia.org/wiki/Projection_orthographique

相关问题