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,

  • 0
    The transformation cannot be linear, because a linear one would map a rectangle to a parallelogram. Therefore there may not be a unique natural transformation that would automatically suggest itself. But don't the texture mapping routines do exactly this type of transformations all the time? Even taking into account the projection from 3D world to the 2D screen (and thus finding a *natural* transformation). Have you looked at the descriptions of those for help/suggestions?2011-09-10
  • 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