kaolin icon indicating copy to clipboard operation
kaolin copied to clipboard

change_coordinate_system

Open zuofy opened this issue 9 months ago • 3 comments

Image Is there an issue here? When I used the change_coordinate_system function to invert the directions of the y-axis and z-axis (OpenCV → OpenGL), the c2w and w2c matrices did not update correctly. Is there a problem with my configuration? Or should the statement in the change_coordinate_system function (self.R = self.R @ basis_change) be modified?

zuofy avatar Mar 25 '25 07:03 zuofy

Hi @zuofy -

you're attempting to follow this conversion: Image

so you did right by negating the axes in the basis change matrix.

What were the target W2C and C2W matrices you expected after the basis change? I see the new W2C has the 2nd and 3rd columns negated, and the C2W matrix has the 2nd and 3rd rows negated, that should be the intended behavior

orperel avatar Mar 25 '25 08:03 orperel

To clarify, see this internal comment which explains the derivation of this function:

        # One prevalent form of performing coordinate change is swapping / negating the inverse view matrix rows.
        # That is - we want to alter the camera axes & position in WORLD coordinates.
        # Note it's enough however, to multiply the R component of the view matrix by the basis change matrix transpose
        # (recall we rotate about the world origin, which remains in place).
        #
        # Compare the inverse matrix before after basis change:
        #               Pre basis change:
        #     view_matrix =             inverse_view_matrix =           Rt is R transposed
        #       [ R | t ]                 [ Rt | -Rt @ t ]              @ denotes matrix column multiplication
        #       [ 0 | 1 ]                 [ 0  |   1     ]
        #
        #               Post basis change:
        #     view_matrix =             inverse_view_matrix =                    P is the basis change matrix
        #       [ R @ Pt | t ]                 [ P @ Rt | -(P @ Rt) @ t ]        Pt is the transposition of P
        #       [ 0      | 1 ]                 [ 0      |       1       ]
        #
        #                                =     [ P @ Rt | P @ (-Rt @ t) ]
        #                                      [ 0      |       1       ]

orperel avatar Mar 25 '25 08:03 orperel

Stale issue, please reopen if still relevant

github-actions[bot] avatar May 24 '25 21:05 github-actions[bot]