I'm trying to build a custom coodinate system. To be more precise, the user chooses three points on the screen to define the coordinate system. The first is the origin, the second is used to build the OX axis, the third OZ and the last OY. The system is properly constructed. The axes are perpendicular to each other.
Once this coordinate system is built, I need to convert the orientation and position of objects placed on the screen from world space to this particular world space. To do this, I tried the solution proposed from here 1. It seems to work, but only for the post. The orientation seems not to change at all.
For example, if I place a cube at (0, 0, 0) without rotating it in world space, in my own coordinate system, it must also be at (0, 0, 0) and it does not should not be rotated relative to my own coordinate system. So the cube in my coordinate system should have a rotation relative to the world space. However, in reality, my code places the cube at my own origin, but does not rotate it accordingly.
In the image below, the first coordinate system (the smallest) is my own system. The other is of world origin. We can see that the WorldObject cube is placed at (0, 0, 0) with rotation (0, 0, 0). The OwnObject should be the representation of WorldObject in my system. We can see that the position has changed, but not the rotation.
My question is how can I rotate the second cube accordingly? I tried to define the rotation of the cube to be the orientation of the structure proposed in this solution 1, but it did not seem to rotate correctly. I also tried to use Quaternion.LookRotation, but it didn't work either.
1 How to create a custom set of coordinates based on two points in Unity?