Your question is still very unclear. However, I'm trying a shot in the dark.
Let's start by calculating a model transform for the plane (which transforms the plane lying in the x/y plane to its actual position). The transform you are looking for is the inverse of this matrix.
We can construct the matrix by finding the images of the principals. The origin is quite simple. As you specified, the origin should be mapped to the first point (v1
). The z-axis is also easy. That's the plane's normal. Hence, the matrix is:
/ . . . . \
M = | . . . . |
| p.Normal.X p.Normal.Y p.Normal.Z 0 |
\ v1.X v1.Y v1.Z 1 /
Now comes the part where your description lacks information. We need a local x-axis on the plane. I assume that this axis is defined by the second vector:
Vector3 x = Vector3.Normalize(v2 - v1);
Then, the resulting local y-axis is:
Vector3 y = Vector3.Normalize(Vector3.Cross(p.Normal, x));
And:
/ x.X x.Y x.Z 0 \
M = | y.X y.Y y.Z 0 |
| p.Normal.X p.Normal.Y p.Normal.Z 0 |
\ v1.X v1.Y v1.Z 1 /
As mentioned, you need this matrix' inverse. Hence:
/ x.X y.X p.Normal.X 0 \
M^-1 = | x.Y y.Y p.Normal.Y 0 |
| x.Z y.Z p.Normal.Z 0 |
\ -v1.X -v1.Y -v1.Z 1 /
More compactly, since you don't need the third and fourth dimensions (although this might not be the most convenient representation for SDX):
/ x.X y.X \
T = | x.Y y.Y |
| x.Z y.Z |
\ -v1.X -v1.Y /