0

I have a 3D world, and three points. The points are connected by Vectors, and one side of the "triangle" is selected to be the X axis. The other two axes are computed by (v1.y, -v1.x, 0) and the third being v1 x v2 (cross product).

I have an offset vector, U(u1, u2, u3) which is moving an object on the X, Y, Z axis in the alternate coordinate system (the one made out of vectors).

I want to rotate an in-game object (x,y,z axes) in this arbitrary coordinate system. For example (90, 0, 0) would rotate 90 degrees on the X axis in this alternate system, not in the world.

I also do not want to use Quaternions, as I am not using Unity Engine.

whitejack
  • 9
  • 1
  • Quaternions are not difficult to implement, and most if not all linear algebra / game math libraries implement them, so not using Unity isn't really a valid excuse. That said this can also be easily done with matrices. The three axes of the alternate system form the columns of the rotation matrix from the world basis to the new basis; pre-multiply this with the X rotation matrix in the world basis. – meowgoesthedog Nov 08 '19 at 14:48
  • So what should I include in this matrix? Because the rotation matrix is for one "line" or Vector only, not three of them. – whitejack Nov 08 '19 at 15:22
  • Please read my comment again - I mentioned two matrices, i) rotation around the X axis and ii) one whose columns are given by the alternate axes. The final matrix is given by `ii) * i)`. – meowgoesthedog Nov 08 '19 at 15:27
  • I read it again. The one that's not clear by now is only the i) matrix, (rotation around the X axis). I know that i should get i)*ii) but i do not know from what i should produce i from. – whitejack Nov 08 '19 at 15:32
  • https://en.wikipedia.org/wiki/Rotation_matrix#In_three_dimensions - see the X matrix. And the matrix you need is `ii) * i)` _not_ `i) * ii)` - matrix multiplication is non-commutative. – meowgoesthedog Nov 08 '19 at 15:35
  • So I only need the X matrix, and I can use that for all the three axes (only needing to calculate ii multiple times.) Am I correct? – whitejack Nov 08 '19 at 15:37
  • No need to do that if your only goal is constructing a rotation around an arbitrary axis - see here: https://stackoverflow.com/questions/6721544/circular-rotation-around-an-arbitrary-axis – meowgoesthedog Nov 08 '19 at 15:39
  • I want to achieve something like telling (30,40,25) and it would be rotating the object on the X, Y, Z vectors. Not in the world. Is that sufficient for this purpose? – whitejack Nov 08 '19 at 15:42
  • Yes. Construct `ii)` each time to "convert" the rotation from world space to alternate axes space. – meowgoesthedog Nov 08 '19 at 15:44
  • Sorry, i did not find the formula for the matrix needed to calculate ii). Can you please provide a link or a search phrase? – whitejack Nov 11 '19 at 13:34

0 Answers0