Sign in to follow this  
Cyberwizzard

Transform parallelogram to square

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this