# Unwrapping a cylinder

**URL:** https://discourse.paraview.org/t/unwrapping-a-cylinder/8731
**Category:** ParaView Support
**Created:** [January 5, 2022, 3:03pm UTC](https://discourse.paraview.org/t/unwrapping-a-cylinder/8731 "2022-01-05T15:03:04Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![heisenmech](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/h/dbc845/32.png) [@heisenmech](https://discourse.paraview.org/u/heisenmech)
#### Post date: [January 5, 2022, 3:03pm UTC](https://discourse.paraview.org/t/unwrapping-a-cylinder/8731/1 "2022-01-05T15:03:04Z")

</div>

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+0_kHat”. However, when I plot something, it looks funny. Any idea?

Best.

 ![pforum1](https://discourse.paraview.org/uploads/default/original/2X/4/47516227ce0f18eb62844b2cbb9293acf8369f11.jpeg)  
 ![pforum2](https://discourse.paraview.org/uploads/default/original/2X/7/708447286c3f77e4b17e115154824761d3967e72.jpeg)

---

<div class="post-metadata">

### Author: ![roland](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/r/3ab097/32.png) [@roland](https://discourse.paraview.org/u/roland)
#### Post date: [January 5, 2022, 5:19pm UTC](https://discourse.paraview.org/t/unwrapping-a-cylinder/8731/2 "2022-01-05T17:19:07Z")

</div>

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](https://www.cfd-online.com/Forums/paraview/210976-unwrapping-cylinder-paraview.html#post714726)):

> 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.

---

<div class="post-metadata">

### Author: ![heisenmech](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/h/dbc845/32.png) [@heisenmech](https://discourse.paraview.org/u/heisenmech)
#### Post date: [January 6, 2022, 12:33am UTC](https://discourse.paraview.org/t/unwrapping-a-cylinder/8731/3 "2022-01-06T00:33:10Z")

</div>

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?

 ![pforum3](https://discourse.paraview.org/uploads/default/original/2X/5/5052a765cc0d6b15d08d80e94b3967a81c8e870f.jpeg)

---

<div class="post-metadata">

### Author: ![roland](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/r/3ab097/32.png) [@roland](https://discourse.paraview.org/u/roland)
#### Post date: [January 6, 2022, 10:50am UTC](https://discourse.paraview.org/t/unwrapping-a-cylinder/8731/4 "2022-01-06T10:50:34Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![heisenmech](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/h/dbc845/32.png) [@heisenmech](https://discourse.paraview.org/u/heisenmech)
#### Post date: [January 6, 2022, 11:11am UTC](https://discourse.paraview.org/t/unwrapping-a-cylinder/8731/5 "2022-01-06T11:11:01Z")

</div>

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

Best.
