assuming the same scale factor on both x,y
axises you can: compute rotation angle:
ang = acos(dot(b-a,d-c)/|b-a|*|d-c|)
and scale:
scale = |d-c|/|b-a|
construct 2D homogenuous 3x3 transform matrix with origin = (0,0)
then convert a
to c'
by it and translate by:
translate = d-d'
Another option is to solve this algebraically:
M * p = p'
Where M
is 3x3 homogenuous transfrom matrix
| m0 m1 m2 |
M = | m3 m4 m5 |
| 0 0 1 |
The p=(x,y,1)
is original point (a,b)
and p'=(x,y,w)
is transformed point (c,d)
so it forms this linear system:
m0.ax + m1.ay + m2 = cx
m3.ax + m4.ay + m5 = cy
m0.bx + m1.by + m2 = dx
m3.bx + m4.by + m5 = dy
m0.ux + m1.uy + m2 = vx
m3.ux + m4.uy + m5 = vy
ux = 0.5*(ax+bx)
uy = 0.5*(ay+by)
vx = 0.5*(cx+dx)
vy = 0.5*(cy+dy)
so just solve the m0,m1,m2,m3,m4,m5
and you have the matrix ...
For more info see: