Assuming your relation b = d*tan(theta) is correct (the drawing indicates b = d*tan(theta/2), since it shows theta as the angle between two triangle sides, not between d and one triangle side) and that right and up are P1->P2 and P2->P3 directions, you will have:
b = Mathf.Tan(theta); // theta or theta/2 - see note above
// this way is more compact:
P3 = P1 + b * (Vector3.right + Vector3.up)
P4 = P1 + b * (Vector3.right - Vector3.up)
P5 = P1 - b * (Vector3.right + Vector3.up)
P6 = P1 - b * (Vector3.right - Vector3.up)
// this way is more intuitive:
P2 = P1 + b * Vector3.right;
P3 = P2 + b * Vector3.up;
P4 = P2 - b * Vector3.up
P5 = P4 - 2 * b * Vector3.right;
P6 = P3 - 2 * b * Vector3.right;
Vector3 P1; // point
Vector3 P2; // point
Vector3 D; // direction
float b; // distance between P1 and P2
I’ll assume that the big arrow shows the direction of “D”
To get the vector in x direction (let’s call it Dx) just subtract P1 from P2 To get the vector from the center to P2. To get the second vector in y direction (Dy) you just need to calculate the cross product between D and Dx. Keep in mind that Unity uses a left-handed-system and not the mathematical right-handed-system. The difference is that the calculated vector will point in the opposite direction.
Vector3 Dx = P2-P1;
Vector3 Dy = Vector3.Cross(D,Dx).normalized * b; // normalize and scale it to the same length as Dx which is b
// now just calculate the 4 points
Vector3 P3 = P1 + Dx + Dy;
Vector3 P4 = P1 + Dx - Dy;
Vector3 P5 = P1 - Dx - Dy;
Vector3 P6 = P1 - Dx + Dy;
If P2 is not given than you need more information since the square can be rotated around D. The “normal” way is to calculate the cross product with a world axis to get the first vector. Usually you would use the up-vector as second parameter but there are two cases the calculations would fail: the forward vector points exactly up or down. That would make the cross-product (0,0,0)
If (Mathf.Abs(Vector3.Dot(D,Vector3.up)) < 0.99f)
{
Dx = Vector3.Cross(D,Vector3.up).normalized * b;
}
else
{
Dx = Vector3.Cross(D,Vector3.forward).normalized * b;
}
// Now continue with the code above.
// ...