pythonnumpymath3drotation

How can I transform the points into a fixed form, regardless of their rotation?


We have several points in 3D space. Two of these points lie exactly on the Y-axis. The problem is that the points may have been rotated. Now, how can I transform the points, regardless of their rotation, into a fixed form?

In other words, regardless of the direction in which it has been rotated, it should be transformed into a standard and fixed form.

I would really appreciate your help.

points = np.array([[0.,0.,0.]
 [-0.075135,0.538134,-0.323848]
 [-0.,0.697979,-0.]
 [-0.105474,0.11303,-0.087109]
 [-0.169698,0.267493,-0.465798]])

# points = rotate_points_around_point(points, 180, "y", points[0])

points = np.array([[0.,0.,0.]
 [ 0.075135,0.538134,0.323848]
 [-0.,0.697979,0.]
 [ 0.105474,0.11303,0.087109]
 [ 0.169698,0.267493,0.465798]])}

# points = rotate_points_around_point(points, 20, "y", points[0])

points = np.array([[0.,0.,0.]
 [ 0.181367,0.538134,0.27862]
 [-0.,0.697979,0.]
 [ 0.128906,0.11303,0.045782]
 [ 0.318777,0.267493,0.379667]])

If the points are input into a function with any rotation, the output should be in a fixed form. To give another example, if we imagine a car, the wheels of the car should always be on the ground. The standard form of the car is such that the wheels are on the ground.

points

points

This is just an example with 5 points. There may be 100 points. The important thing is that, with any rotation around the Y-axis, it should be transformed into a fixed form.

What came to my mind is to check which plane the points are closest to. For example, if they are closer to the XZ plane, rotate the points so that they have the least distance from that plane. This idea might not be correct, though.

For example, regardless of the rotation of the input, the output should be transformed as follows:

[[ 0.        0.        0.      ]
 [ 0.075135  0.538134  0.323848]
 [-0.        0.697979  0.      ]
 [ 0.105474  0.11303   0.087109]
 [ 0.169698  0.267493  0.465798]]

I value the insights and guidance you provide.


Solution

  • If I understand correctly, you want to define a standard form for a set of points, such that two sets differing by a rotation about the y-axis will have the same standard form. To do this, represent the points in cylindrical coordinates along the y-axis. That is, if the cartesian coordinates of a point are (x, y, z) then replace them by (r, y, ϕ) where r = √(x^2 + z^2) and ϕ is the angle such that cos ϕ = x/r and sin ϕ = z/r. Then you can take the point with the largest r-coordinate and rotate all points by the angle equal to the negative of the ϕ-coordinate of this point. The set of points after this rotation is in the standard form. If there is more that one point with the same largest r, choose among them a point with the largest y. If there are are several points with the same largest r and y, keep lowering the values of r and y, looking for a point for which these coordinates are unique. This leaves the case where for every r and y there are several points with different ϕ-coordinates. With some extra work it is possible to resolve this case as well.