# How to unwrap cylinder from a particular location

**URL:** https://discourse.paraview.org/t/how-to-unwrap-cylinder-from-a-particular-location/13217
**Category:** ParaView Support
**Tags:** vtk
**Created:** [November 9, 2023, 8:53am UTC](https://discourse.paraview.org/t/how-to-unwrap-cylinder-from-a-particular-location/13217 "2023-11-09T08:53:36Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Mohammed\_Niyasdeen](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mohammed_niyasdeen/32/8395_2.png) [@Mohammed\_Niyasdeen](https://discourse.paraview.org/u/Mohammed_Niyasdeen)
#### Post date: [November 9, 2023, 8:53am UTC](https://discourse.paraview.org/t/how-to-unwrap-cylinder-from-a-particular-location/13217/1 "2023-11-09T08:53:36Z")

</div>

I am trying to unwrap a cylinder (Figure01) from a particular starting point so that the wave comes in the middle when unwrapped.  
But instead, I got this. (Figure02).  
I am using this function to unwrap: 0\*iHat+(atan(coordsY/coordsX)+(coordsX/abs(coordsX))_1.570796326)_(coordsX^2+coordsY^2)^(1/2)_jHat+coordsZ_kHat

My question is how do you unwrap from a different starting point?

![Figure01](https://discourse.paraview.org/uploads/default/original/2X/0/027409fe155d1604db11daa0e131426b648c800d.png)  
 ![Figure02](https://discourse.paraview.org/uploads/default/original/2X/5/5fed7ed021d6fa5b305fb21f3b62f176b1d6a88f.png)

---

<div class="post-metadata">

### Author: ![Kenneth\_Moreland](https://discourse.paraview.org/user_avatar/discourse.paraview.org/kenneth_moreland/32/15033_2.png) [@Kenneth\_Moreland](https://discourse.paraview.org/u/Kenneth_Moreland)
#### Post date: [November 9, 2023, 1:54pm UTC](https://discourse.paraview.org/t/how-to-unwrap-cylinder-from-a-particular-location/13217/2 "2023-11-09T13:54:36Z")

</div>

First of all, I recommend changing `atan(coordsY/coordsX)` to `atan2(coordsY,coordsX)`. The latter is a safer way of computing arctan that avoids divide-by-zero and determines the quadrant correctly. Once you do that, I believe you can remove the `(coordsX/abs(coordsX))` part, which I think is trying to address the quadrant problem.

The unwrapping point of `atan2` will always be at \pi, but you can rotate your cylinder around the Z axis to change where that \pi position is. A simple math trick to [rotate a 2D axis](https://www.mometrix.com/academy/rotation/) by 90^\circ clockwise is to replace (x,y) \rightarrow (y,-x) (i.e. use `atan2(-coordsX, coordsY)`). LIkewise 180^\circ is (x,y) -\> (-x, -y) and 270^\circ is (x,y) \rightarrow (-y, x).

Or an even easier way that allows for placing the \pi split in an arbitrary position is to apply the `Transform` _before_ the calculator. Rotate the cylinder around the Z axis.

---

<div class="post-metadata">

### Author: ![Mohammed\_Niyasdeen](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mohammed_niyasdeen/32/8395_2.png) [@Mohammed\_Niyasdeen](https://discourse.paraview.org/u/Mohammed_Niyasdeen)
#### Post date: [November 10, 2023, 12:11am UTC](https://discourse.paraview.org/t/how-to-unwrap-cylinder-from-a-particular-location/13217/3 "2023-11-10T00:11:09Z")

</div>

Thanks Kenneth. It was really helpful.

I got the unwrapped image like this (Figure01). I have also attached another picture (Figure02) showing the settings. Do you know why I am getting gaps in between?

 ![Figure01](https://discourse.paraview.org/uploads/default/original/2X/9/93d702ee6e08affd80e73cb2146c7cdf47b0355e.jpeg)

 ![Figure02](https://discourse.paraview.org/uploads/default/original/2X/0/0ea51ddceb9a36859395a6515de68849c818bc22.png)

---

<div class="post-metadata">

### Author: ![Kenneth\_Moreland](https://discourse.paraview.org/user_avatar/discourse.paraview.org/kenneth_moreland/32/15033_2.png) [@Kenneth\_Moreland](https://discourse.paraview.org/u/Kenneth_Moreland)
#### Post date: [November 10, 2023, 2:40pm UTC](https://discourse.paraview.org/t/how-to-unwrap-cylinder-from-a-particular-location/13217/4 "2023-11-10T14:40:31Z")

</div>

It would help if you share your data, but this might be the same as an issue I ran into when answering your question in that there are polygons that stretched across the plane.

When you converted coordinates to angles, there are some polygons with some points a little less than 180^\circ and others that are a little more than -180^\circ. When drawn as a round cylinder, these points are close to each other. But when the angle is drawn in the x/y plane, these points are on opposite sides of the image. That means the polygons stretch across your entire image and intersect everything. That can create z-buffer fighting that can cause artifacts in the rendering like what you are seeing.

You will have to identify those polygons and remove them. How to do that depends on your data. One way is to use the `Cell Size` filter to compute the area of your polygons. Then remove the largest polygons, which are probably the ones that are stretched across your data.

---

<div class="post-metadata">

### Author: ![Mohammed\_Niyasdeen](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mohammed_niyasdeen/32/8395_2.png) [@Mohammed\_Niyasdeen](https://discourse.paraview.org/u/Mohammed_Niyasdeen)
#### Post date: [November 10, 2023, 11:58pm UTC](https://discourse.paraview.org/t/how-to-unwrap-cylinder-from-a-particular-location/13217/5 "2023-11-10T23:58:19Z")

</div>

Thanks Kenneth.  
Do you know, how can I share the data of size 2GB here?

I never used this “Cell Size” filter. Can you please guide how to remove the largest polygons using that? Attached is the Figure showing the properties pane of “Cell Size” filter.

 ![CellSize Filter](https://discourse.paraview.org/uploads/default/original/2X/6/6b136d0e063cbe01b51e3e1d59ec7b50109ee385.png)

---

<div class="post-metadata">

### Author: ![Kenneth\_Moreland](https://discourse.paraview.org/user_avatar/discourse.paraview.org/kenneth_moreland/32/15033_2.png) [@Kenneth\_Moreland](https://discourse.paraview.org/u/Kenneth_Moreland)
#### Post date: [November 11, 2023, 4:53pm UTC](https://discourse.paraview.org/t/how-to-unwrap-cylinder-from-a-particular-location/13217/6 "2023-11-11T16:53:34Z")

</div>

Information about file sharing is in the FAQ: [I want to share data here, how can I do that ?](https://discourse.paraview.org/t/i-want-to-share-data-here-how-can-i-do-that/5296)

The `Cell Size` filter itself will not remove the data. It will create a new field that has the area of each polygon in your mesh. Once you have that, you can use something like the `Threshold` filter to remove the polygons with the largest size.
