Skip to main content
gamedev.net
🔒 Locked 🎮 Unity

Transform parallelogram to square

Started by Cyberwizzard Dec 1, 2004 at 10:56 AM 0 replies 1.7k views
Original Post
Cyberwizzard
Cyberwizzard
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...

Topic Locked

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

Sign in to reply to this topic.