Reputation: 816
I have a 3D object in space. Here it is from a top-down perspective:
Y is towards us, so we can't see that axis. It's not tilting at all, so it's direction would be Vector2(0,0).
Now the object is tilting forward. It's tilting towards the positive X axis. The direction would now be Vector2(0,1)
Now it's tilting to the left, it's direction would be Vector(-1,0)
Now, finally, it's tilting forward and the left, it's direction would be around Vector(-0.7071, 0.7071)
I'm using Unity, so I have access to the object's Quaternion and Euler Angles as a Vector3. How would I calculate the object's tilt direction from the object's rotation?
Upvotes: 0
Views: 594
Reputation: 558
As far as I understand your idea, you are looking for orthogonally casted parameters of normal vector (abstractly attached to the body). If it turns forward this vector after cast gets values (0,1) like you've said.
You can receive x and y components of that vector by decomposition - as a sum of two perpendicular vectors, each one represents one component (x,0) and (0,y).
Another way of achieving that result would be to have a point in 3D space P(0,0,1) which represents top of such vector. Now simply applying rotation matrix this point would be moved toward new position which is P(x,y,z) and here you can get x and y you are looking for.
I hope I didn't messed up something.
Upvotes: 1