Given two diagonally opposite points on a square, how to calculate the other two points I'm not a mathematician, just a programmer working on a (pro bono) job with a bit of geometry involved.
Basically I have two points A(a,b) and B(c,d) (For what it's worth, these are geographical coordinates.)
I have two scenarios to work out. In the first scenario, these two points are opposite vertices of a square, and I need to work out the coordinates of the other two vertices.
I thought I was onto something with this post: Given coordinates of hypotenuse, how can I calculate coordinates of other vertex? which seems to be in the right ballpark, but I am stuck at the step where you need to subtract two linear equations. However, in my case the lengths of the sides are equal, so it should be easier?
In my second scenario, the two points are centrepoints on the opposite sides of a square (so that the distance AB is also the length of each side of the square) and from this I need to derive the coordinates of all four sides.
I'm pretty confident that if I can work out scenario 1, I can also work out scenario 2, but any advice on either would be gratefully received.
Added Later:
Thanks very much for your help. For information, here is how I tackled scenario 2 (just in case anyone ever wants to reproduce something similar.) This could probably be tidied up, but will work for the moment. (Haven't checked this code, just transcribed it from my program. It's C#.)
public List<Point> GetVertices(double x1, double y1, double x2, double y2)
{
// x1,y1 are point A coordinates, x2,y2 are point B coordinates
// Centrepoint calculation
var cX = (x1 + x2) / 2;
var cY = (y1 + y2) / 2;

// Length of Side
var pLen = Math.Sqrt(((y2 - y1) * (y2 - y1)) + ((x2 - x1) * (x2 - x1)))

// Length of Diagonal
var diagLen = Math.Sqrt(pLen*pLen + pLen*pLen);

// Ratio of Diagonal to Side
var ratio = diagLen / pLen;

// Now use centrepoint and one of the existing points to find a new vertex
var newX = cX + ratio*(x2 - cX);
var newY = cY + ratio*(y2 - cY);

// Make some points for rotation
var pCentre = new Point(cX, cY);
var pNew = new Point(newX, newY);

var vertices = new List<Point>();
// Now rotate the points
var p1 = RotatePoint(pNew, pCentre, 45);
vertices.Add(p1);
var p2 = RotatePoint(p1, pCentre, 90);
vertices.Add(p2);
var p3 = RotatePoint(p2, pCentre, 90);
vertices.Add(p3);
var p4 = RotatePoint(p3, pCentre, 90);
vertices.Add(p4);

return vertices;

}

private Point RotatePoint(Point rotater, Point centre, double angleInDegrees)
{
        double angleInRadians = angleInDegrees * (Math.PI / 180);
        double cosTheta = Math.Cos(angleInRadians);
        double sinTheta = Math.Sin(angleInRadians);
        return new Point
        {
            X = 

                (cosTheta * (rotater.Longitude - centre.Longitude) -
                sinTheta * (rotater.Latitude - centre.Latitude) + centre.Longitude),
            Y = 

                (sinTheta * (rotater.Longitude - centre.Longitude) +
                cosTheta * (rotater.Latitude - centre.Latitude) + centre.Latitude)
        };

}

 A: Given two opposite corners of the square we can calculate the length of the diagonal $$D = \sqrt{(c-a)^{2} + (d-b)^{2}}.$$
From the length of the diagonal we can calculate the length of the sides, $$S = \frac{1}{\sqrt{2}}D.$$
Now imagine the following - we draw a circle with radius $S$ centered at the point $A$ and a second circle of radius $S$ at the point $B$. The two points where these circles intersect are the corners we are looking for. The equations for these two circles are:
$$(x-a)^{2} + (y-b)^{2}= S^{2}$$
$$(x-c)^{2} + (y-d)^{2}= S^{2}$$
Now we will expand these two equations then subtract them. First we expand:
$$x^{2} - 2ax + a^{2} + y^{2} - 2by + b^{2} = S^{2}$$
$$x^{2} - 2cx + c^{2} + y^{2} - 2dy + d^{2} = S^{2}$$
Now we subtract
$$ 2x(c-a) + a^{2} - c^{2} + 2y(d-b) + b^{2} - d^{2} = 0.$$
Rearrange this equation to find an expression for $y$,
$$y = -x\frac{c-a}{d-b} + \frac{c^{2} + d^{2} - a^{2} - b^{2}}{2(d-b)}.$$
Now substitute this expression for $y$ into one of the equations of the circle and solve for $x$.
A: Here is the code for the first problem:
  x1 = ?  ;  y1 = ? ;    // First diagonal point
  x2 = ?  ;  y2 = ? ;    // Second diagonal point

  xc = (x1 + x2)/2  ;  yc = (y1 + y2)/2  ;    // Center point
  xd = (x1 - x2)/2  ;  yd = (y1 - y2)/2  ;    // Half-diagonal

  x3 = xc - yd  ;  y3 = yc + xd;    // Third corner
  x4 = xc + yd  ;  y4 = yc - xd;    // Fourth corner

A: Define for any vector $(a_1,a_2)$ in $R^2$ the map $J(a_1,a_2):=(-a_2,a_1)$; it's the rotation of that vector by 90 degrees. Then, if $A$ and $B$ are opposite corners, the other two must obviously be
$$\frac 12(A+B)\pm\frac 12 J(B-A)=\frac 12 \bigl(A+B\pm J(B-A)\bigr).
$$
Example: $A=(2,6)$, $B=(10,2)$, then $A+B=(12,8)$ and $J(B-A)=(4,8)$, so the edges are $(8,8)$ and $(4,0)$.
Michael
A: Find the coordinates to the centre $(\frac{a+c}2,\frac{b+d}2)$, then use rotation from complex numbers, this is better than going for long algebric manipulations. 
$z_2-z_1=\frac{|z_2-z_1|}{|z_3-z_1|}{(z_3-z_1)}e^{i\theta}$
A: Since it is a sqaure so it is somewhat easier. Below is the algorithm you can use :)
Let us say the 2 vertices are A and C (i.e diagonally opposite)
Step 1) Calculate the midpoint between A and C using midpoint theorem. Let us say it as M.
Step 2) Calculate the distance between the midpoint M and anyone vertice of the square. Let us assume the distance to be X.
Step 3) Now as we know that the diagonals in square bisect at 90, so use the harversine formula(https://www.movable-type.co.uk/scripts/latlong.html) with points as the midpoint and bearing as 90 degrees and distance X.
Ste 4) Here you go you got your first point and for the second point just take bearing as -90 degrees. 
Hope it helps worked for me and is pretty much accurate too!
