Skip to main content
gamedev.net
🔒 Locked

Matrix question

Started by v_d_d Feb 24, 2003 at 1:49 PM 1 replies 300+ views
Original Post
v_d_d
v_d_d
Hi, How can I build a matrix that when multiplied by Vector1, it will result in Vector2. The 2 vectors are known. How do I find the matrix?
LilBudyWizer
LilBudyWizer
There is an infinite number of matrices. One of them is an axis-angle rotation and scaling. Going from A to B the scaling factor is |B|/|A| where |A| is the magnitude of A. Your axis of rotation is A X B /(|A||B|) where A X B is the cross product. The cosine of the angle of rotation is A.B/(|A||B|) where A.B is the dot product. cos(t)=cos(-t) but here it doesn''t matter because if the angle is negative then the axis points the opposite direction and it is still a positive rotation.

That provide a logical way to choose a matrix. All that really matters as stated is that it adds up. You can simply form a diagonal matrix from B/A where the "/" is component by component division, i.e. (B1, B2, B3) / (A1, A2, A3) = (B1 / A1, B2 / A2, B3 / A3). The result of the matrix multiplication will be (A1 * B1 / A1, A2 * B2 / A2, A3 * B3 / A3) = (B1, B2, B3). You don''t really need a matrix to do that.
Keys to success: Ability, ambition and opportunity.
v_d_d
v_d_d
Thanks for the reply. In the meantime, I also checked the Matrix and Quaternion FAQ and found a similar answer in the ''How to map a vector on to another?''.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.