# [Math] Get Transformation Matrix from M*v = v'?

Discussion in 'Plugin Development' started by narrowtux, Apr 5, 2011.

Not open for further replies.
1. Offline

### narrowtux

Hi,
I want to dynamically generate a transformation matrix out of two given vectors.
Given is this formula:
M*v = v',
where M is a 3x3-Matrix, and the vectors v and v' are given and contain x,y,z-coords.
Is it possible to solve this equation-system via an algorithm? I already read about the Gauß' algorithm but I don't know if that is suitable for this kind of equation system and if yes, how to insert the vector into the initial matrix.

#1
2. Offline

### Edward Hand

Gaussian elimination would be useful for finding v if you had M and v'. It doesn't work in this situation.

The problem is that there would be many valid matrixes that solve that equation for given v and v' - not one single one. Unless you have at least a little information about the nature of M, you won't be able to find one single solution.

#2
3. Offline

### narrowtux

The transformation matrix is a rotation-matrix.

#3
4. Offline

### Edward Hand

Do you know the origin of the rotation? (I'm fairly sure you need to).

#4
5. Offline

### narrowtux

The origin is (0,0,0).
To go more into detail:
I want to create a Portal-like gameplay which requires to transform both the momentum and the view of the player whenever he goes through a portal. Each portal has got a vector which points out of the portal
(

--->

)
Hope that makes it clear

#5
6. Offline

### Edward Hand

Ah I get you.

Do your portals only have 4 possible directions (North/South/East/West)?

If so, then its fairly easy to rotate by 90 degrees about the vertical axis (without going as far as using matrices).

#6
7. Offline

### narrowtux

No, they also should go up and down...
Maybe it's also possible to do this without vectors.

#7