5
$\begingroup$

I have a math problem for some code I am writing. I don't have much experience with 2D transformations, but I am sure there must be a straight-froward formula for my problem.

I have illustrated it here:

transformation

My goal is to work out the co-ordinates of (Xp2, Yp2).

Shape A is a quadrilateral that exists that can exist anywhere in 2D space. Its four co-ordinates are known. It contains a point (Xp1, Yp1), which are also known.

Shape B is a rectangle with one corner at (0,0). The height and width are variable, but known.

Shape A needs to be transposed to Shape B so that the new position of the point inside can be calculated.

How do I work out the new co-ordinates of (Xp2, Yp2)?

Cheers,

  • 1
    @Jyrki: there is a unique perspective transform that maps 4 points to 4 points, as long as no 3 points are collinear.2011-09-10

1 Answers 1

2

See my answer to "Tranforming 2D outline into 3D plane". The transforms and 4 point to 4 point mapping described there should be just what you need.

  • 0
    @Martin: that algorithm has been tested thoroughly in [QuickDraw GX](http://en.wikipedia.org/wiki/QuickDraw_GX). While we usually used the Camera Library to generate perspective matrices, we also used this algorithm (Poly2PolyMap) to generate perspective matrices that didn't originate from 3-D data.2011-09-15