# Unwrapping a cylinder

Hi all,

I’m trying to unwrap a cylindrical surface. I managed to unwrap it using “coordsX*iHat+(atan(coordsY/coordsZ) + (coordsZ/abs(coordsZ))1.570796326)(coordsZ^2+coordsY^2)^(1/2)jHat+0kHat”. However, when I plot something, it looks funny. Any idea?

Best.

Can it be that your surface is folded back on it self because you use an atan function instead of atan2?

I don’t know if atan2 is available now, but it wasn’t before, so I used to calculate it myself with a Calculator filter:

if(coordsX>0,atan(coordsY/coordsX), if(coordsX<0, if(coordsY<0,atan(coordsY/coordsX)-4*atan(1),atan(coordsY/coordsX) +4 *atan(1)), if(coordsY>0, 2 *atan(1), if(coordsY<0, -2 *atan(1),0))))

Then apply a [-pi, pi] threshold on the resulting angle (which I called theta).

Finally I apply this Calculator (which you may have already found here):

Coords_flat = sqrt(coordsX^2+coordsZ^2) * theta * iHat+coordsY * jHat+0 * kHat

You will need to change your coordsX,Y,Z to fit your cylinder orientation of course.

Hi Roland,

Thanks for the reply. I think you are right about the atan2. However, I still don’t seem to get the shape quite right. If I want to unwrap from the bottom red line shown in the pic (towards y+), how should I modify the theta and the coords for the current orientation?

Your cylinder axes is in X direction and crosses the origin point? I think that then this should work, but I haven’t checked it:

if(coordsY>0,atan(coordsZ/coordsY), if(coordsY<0, if(coordsZ<0,atan(coordsZ/coordsY)-4* atan(1),atan(coordsZ/coordsY)+4* atan(1)), if(coordsZ>0,2* atan(1), if(coordsZ<0,-2* atan(1),0))))

Coords_flat = coordsX* iHat+sqrt(coordsY^2+coordsZ^2)* theta* jHat+0*kHat

If it doesn’t work then go over the equations carefully to match your cylinder orientation.

This may sound ridiculous but keeping the seven decimal points of pi (instead of eleven) worked like a charm. Thanks Roland.

Best.