0

I try to bend a plane mesh using spherical coordinates. I token formulas on wikipedia and it almost work ! But some vertices are positionned to the same place. The mesh plane is placed at 0,0,0, you can watch the result here :

Before : http://hpics.li/78c0871

After : http://hpics.li/19ada1a

And here is my code :

@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) 

Thanks for help !

user1118321
  • 25,567
  • 4
  • 55
  • 86
Tiramitsu
  • 61
  • 10
  • Ok, i found a solution with the Mercator projection here : http://stackoverflow.com/questions/12732590/how-map-2d-grid-points-x-y-onto-sphere-as-3d-points-x-y-z – Tiramitsu Nov 02 '14 at 13:51

1 Answers1

0

Sorry for that, but the formulas concern le orthographic projection as you can see here : http://fr.wikipedia.org/wiki/Projection_orthographique

Tiramitsu
  • 61
  • 10