Reputation: 2010
There is a triangle with points P1(x1,y1)
,P2(x2,y2)
,P3(x3,y3)
on an XY plane.
The final position after transformation are known to us, P1'(x,y)
and P2'(x,y)
How can I find the third point?
Using slope (or distance) formula gives two solutions (one is mirror image of another). Assuming the transformation is a combination of translation and rotation, how do I get the new coordinates of the final point P3'
?
Upvotes: 0
Views: 280
Reputation: 80127
If you already have got solution using distance formula, you need only to choose what mirror point is needed. To clarify, find sign of cross product of P1P2
vector and P1P3
vector. Then find sign of cross product of of P1'P2'
vector and P1'Px
vector. If signs differ, get another point.
CrossProduct = (P2.X - P1.X) * (P3.Y - P1.Y) - (P2.Y - P1.Y) * (P3.X - P1.X)
In general case you can find transformation matrix coefficients and apply this matrix to the third point
c -s 0
M = s c 0
dx dy 1
equation system
c * x1 + s * y1 + dx = x1'
-s * x1 + c * y1 + dy = y1'
c * x2 + s * y2 + dx = x2'
-s * x2 + c * y2 + dy = y2'
solve it for unknown c, s, dx, dy (really c and s are not independent)
Upvotes: 1