Jump to content
  • Advertisement
Sign in to follow this  
Cyberwizzard

Transform parallelogram to square

This topic is 5040 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

I got a parallelogram and a point inside the parallelogram - now I need to transform the point inside to a 2d point in a square. I tried working with diagonals and tried some stuff with matrixes but I can't get it right... For arguments sake I'll explain what I'm doing right now (I don't fully understand if this is correct): 1. Take the points of the parallelogram and call bottom left point A, bottom right B, top right C and top left D. The point inside will be called i (from intersection) 2. I transpose every point by A: A = A - A B = B - A C = C - A D = D - A i = i - A 3. Use the A->B and A->D as the axis in our scewed axis system, since all points are in the same plane, I can use the normal vector as the 3rd axis and generate a matrix accordingly: Matrix: Column1: B (was B - A) Column2: D (was D - A) Column3: (C-A)*(B-A) (= normal of plane if I'm not mistaken) 4. Invert this matrix 5. Transform the i (was i - A) using the matrix, or in code (I'm using Java): matrix.transform(i) After those steps I should have the 2d (I can ignore z as it will be 0) coordinate inside the parallelogram... right? For some reason it seems this is going astray somewhere along but I can't figure out what is going wrong exactly...

Share this post


Link to post
Share on other sites
Advertisement
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!