# Spherical Mapping problem

This topic is 4296 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi, I use following to convert Cartesian to Spherical system to generate texture coordinats for my sphere model, but error on some parts. Can someone help? Image 1: Image 2: procedure Cartesian2Spherical(const dx,dy,dz:GLFloat; var scRad, scPhi, scTheta:Glfloat); begin scRad:=sqrt(dx*dx + dy*dy + dz*dz); if (dy>0.0) then scPhi:=ArcCos(dy/scRad) else scPhi:=PI-ArcCos(-dy/scRad); if (dx=0.0) and (dz>0.0) then scTheta:=PIdiv2; if (dx=0.0) and (dz<0.0) then scTheta:=PI+PIdiv2; if (dx>0.0) and (dz=0.0) then scTheta:=0.0; if (dx<0.0) and (dz=0.0) then scTheta:=PI; if (dx<>0.0) and (dy<>0.0) then begin if (dx>0.0) and (dz>0.0) then ang :=0.0; if (dx<0.0) and (dz>0.0) then ang :=PI; if (dx<0.0) and (dz<0.0) then ang :=PI; if (dx>0.0) and (dz<0.0) then ang :=PI2; scTheta:=ArcTan(dz/dx)+ang; end; end; texturecoord.s := scTheta / _2PI; texturecoord.t := (PI-scPhi) / PI; Thanks a lot, Daniel

1. 1
2. 2
3. 3
Rutin
25
4. 4
5. 5
khawk
14

• 11
• 11
• 23
• 10
• 9
• ### Forum Statistics

• Total Topics
633649
• Total Posts
3013117
×