Calculate the new coordinates of points after the plane of the points is transformed

Hi guys,

  1. I have 4 points(p0, p1, p2, p3) in the same plane; I know the coordinates all of these.

  2. Then the plane is translated and rotated,(not scaled); I know the new coordinates of p0, p1, p2; I don’t know the coordinate of p3.

  3. How can I calculate the new coordinate of p3?

  4. What I current do, but not working:
    4.1 Init status:

    Vector3 initP0;
    Vector3 initNormal;
    Vector3 initP3;
    void beforeTransform(Vector3 p0, Vector3 p1, Vector3 p2, Vector3 p3)
    {
    &nbsp&nbsp&nbsp initP0 = p0;
    &nbsp&nbsp&nbsp initNormal = Vector3.Cross(p1-p0, p2-p0);
    &nbsp&nbsp&nbsp initP3 = p3;
    }

4.2 The plane is translated and rotated,(not scaled)

Vector3 afterTransform(Vector3 p0, Vector3 p1, Vector3 p2)  
{  
&nbsp&nbsp&nbsp     Vector3 new_normal = Vector3.Cross(p1-p0, p2-p0);  
&nbsp&nbsp&nbsp     Vector3 translation = p0-initP0;   
 &nbsp&nbsp&nbsp    Quaternion rotation = Quaternion.FromToRotation(normal, initNormal);  
 &nbsp&nbsp&nbsp    Matrix4x4 matrix4x4 = Matrix4x4.TRS(translation, rotation, Vector3.one);  
 &nbsp&nbsp&nbsp    return matrix4x4.MultiplyPoint3x4(initP3);  
}  

Thanks in advance.

Saving just the normal of the plane isn’t enough. The normal and a point defines a plane, but such a plane doesn’t have an orientation around the normal.

The easiest way is to save the position of the 4th point in relation to the other points.

One way is to express the point as a 2d vector within the plane. As unit vectors you would use the vectors p0->p1 and p0->p2.

Something like that:

public Vector2 pos;

void beforeTransform(Vector3 p0, Vector3 p1, Vector3 p2, Vector3 p3)
{
    Vector3 a = (p1 - p0);
    Vector3 b = (p2 - p0);
    Vector3 c = (p3 - p0);
    pos = new Vector2(Vector3.Dot(a, c) / a.sqrMagnitude, Vector3.Dot(b, c) / b.sqrMagnitude);
}

Vector3 afterTransform(Vector3 p0, Vector3 p1, Vector3 p2)
{
    Vector3 a = (p1 - p0);
    Vector3 b = (p2 - p0);
    return p0 + a * pos.x + b * pos.y;
}

Another way would be to calculate the barycentric coordinates of your 4th point in relation to the triangle that p0, p1, p2 define. To get new position you just need to use the barycentric coordinates with the new points.

In both cases the new point will also scale and even skew with the new points.