Jump to content
  • Advertisement
Sign in to follow this  
Tylon

Finding the transformation matrix from one line to another

This topic is 4871 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

(2D) I have two line segments A and B. The start and end point of each line is not neccessarly 0, they are free floating, unrelated lines with parameters x0, y0, x1, y1 representing their endpoints. I want to find the the 2D (3*3) transformation matrix that translates, rotates and scales line A to line B. Can anyone help me please?

Share this post


Link to post
Share on other sites
Advertisement
you can do it only by using a matrix that transforms from Line1xOrthogonal of that line to the newlinexnewOrthogonal. All your points not on the line will also be transformed and be placed in relation to the line...

so...
cx, cy is the startpoint,
ax, ay is the endpoint relatively to the center (ax= realendpointx-cx, ay=realendpointy-cy) and
bx, by is the Orthogonal with bx= ay, by= -ax (90°CW rotated)

the matrix will then be:

ax bx cx ax ay cx
ay by cy or without bx,by: ay -ax cy
0 0 1 0 0 1
this transforms from x=0 to 1 onto the line and y=0 to 1 onto the Orthogonal
(0, 0) => line startpoint, (1,0) => line endpoint (the third component, w is 1)

you need the extra Orthogonal to get the inverse of that matrix (otherwise you lose one degree of freedom and the determinant of the matrix becomes 0 => no inverse)

ive decided to not give you a formula for the inverse because that will become a bit complicated and you can google for such a formula...

all you have todo now is to get the matrix for line1->objspace->line2, where line1->objspace is the inverse of the above matrix with line1 coordinates and objspace->line2 is the above matrix with line2 coordinates


edit: codetag
edit2: tangent replaced with orthogonal
T2k

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!