Using two diagonal points to find remaining points of rectangle

I have two Vector3 points which will define the diagonal points of a rectangle in world-space. I can acquire the unknown points of the rectangle simply by combining the x and z values of both A and B

Known diagonal points:
Vector3 a = (4, 1, 16)
Vector3 b = (18, 1, 4)

Remaining points…
Vector3 c = (a.x, 1, b.z)
Vector3 d = (b.x, 1, a.z)

Rather then setting all the points manually I’m curious if there’s a loop formula (given 2 Vector3’s) that can find the remaining points of a rectangle as well as 4 additional points on a higher Y axis to make up a 3d rectangle? Ideally the points will be in consecutive order that way I can linecast between each one

You could use a function like this:

    //using System.Collections.Generic;

    Vector3 a = new Vector3(4, 1, 16);
    Vector3 b = new Vector3(18, 1, 4);
	
	void Start () {
        List<Vector3> firstRect = GetRect(a, b); //Your first Rectangle specified
        List<Vector3> secondRect = GetRect(a, b, 0.5f); //A second Rectangle 0.5 units above the first
	}
	
    public List<Vector3> GetRect(Vector3 a, Vector3 b, float yOffset = 0)
    {
        return new List<Vector3> {new Vector3(a.x, a.y + yOffset, a.z), new Vector3(b.x, b.y + yOffset, b.z), 
                                    new Vector3(a.x, a.y + yOffset, b.z), new Vector3(b.x, a.y + yOffset, a.z)};
    }

You could just store the two points in their own variable like this:

    Vector3 c = new Vector3 (a.x, 1, b.z);
    Vector3 d = new Vector3 (b.x, 1, a.z);

Otherwise I’m not sure how you would do this.