I have a point cloud of a ring captured with a profilometer (laser) that looks like this

And I want to transform it in order to get its original round shape back. All the info I have is the XYZ coordinates of the cloud.
I've tried two different methods but none worked.
Method 1:
x_min = 0
x_max = 360
D = 1
x_coordinates = xyz[:, 1]
y_coordinates = xyz[:, 0]
z_coordinates = xyz[:, 2]
theta = (x_coordinates - x_min)/(x_max - x_min)*2*np.radians(180)
gamma = D - y_coordinates
x_round = gamma * np.cos(theta)
y_round = gamma * np.sin(theta)
z_round = z_coordinates
assert x_round.ndim == 1 and y_round.ndim == 1 and z_round.ndim == 1, "Arrays must be 1-dimensional"
points = np.stack((x_round, y_round, z_round), axis=-1) # Stack arrays along a new axis to get Nx3
pcd = o3d.geometry.PointCloud()
pcd.points = o3d.utility.Vector3dVector(points)
o3d.visualization.draw_geometries([pcd], window_name="Original Shape")
Method 2:
def cart2sph(x, y, z):
xy = np.sqrt(x**2 + y**2) # sqrt(x² + y²)
x_2 = x**2
y_2 = y**2
z_2 = z**2
r = np.sqrt(x_2 + y_2 + z_2) # r = sqrt(x² + y² + z²)
theta = np.arctan2(y, x)
phi = np.arctan2(xy, z)
return r, theta, phi
Every (X,Y,Z) pair is, conceptually, associated with the pose of the scanner that acquired it, a rotation and translation (R, t) with respect to some global coordinate frame - for example, the frame of the first scan. Depending on the device, whole sets of points ("patches", "strips", "lines") will have been acquired at each pose. It is then a matter of transforming each set into the global frame by applying its associated device rotation and translation.
If the calibration / pose tracking of the device is good enough (i.e. as accurate as the point measurements), that's all there is to it. Often, though, the scanner is more accurate than the pose tracker, with the effect that the point sets won't line up exactly after being transformed to a global frame. In this case, the alignment can be refined using the data themselves and some constraints - using algorithms that collectively fall under the umbrella of "iterative closest point".