I'd avoid all that trigonometry. For one of the edge directions, you want a vector which is at the same time perpendicular to V1 − V2 and to the Y axis. The cross product can be used to obtain a vector which is perpendicular to two given ones. So you compute it like this:
[ 0 ] [ x2 − x1 ] [ z2 − z1 ] [ dz ]
[ 1 ] × [ y2 - y1 ] = [ 0 ] = [ 0 ] = w₁
[ 0 ] [ z2 - z1 ] [ x1 − x2 ] [ −dx ]
For the second edge direction, you want to be perpendicular to that first one, and also perpendicular to V1 − V2 again. So the same story:
[ dz ] [ dx ] [ dx*dy ] [ ex ]
[ 0 ] × [ dy ] = [ − dx² − dz² ] =: [ ey ] = w₂
[ −dx ] [ dz ] [ dz*dy ] [ ez ]
You'll have to normalize these vectors to ensure they have length 1, then you are done. In. fact I'd normalize them to length ½ because then you can use ± that vector to describe positions which are symmetric around the origin, the way your own code does it as well. For the corners you then need ±w1±w2, which gives four possible sign combinations.
public FourVert(Vert V1, Vert V2, float t)
{
float dx = V2.x - V1.x;
float dy = V2.y - V1.y;
float dz = V2.z - V1.z;
float ex = dx*dz;
float ey = -dx*dx-dz*dz;
float ez = dz*dy;
float d = (float)(t/(2*Math.sqrt(dx*dx+dz*dz)));
float e = (float)(t/(2*Math.sqrt(ex*ex+ey*ey+ez*ez)));
dx *= d; dz *= d;
ex *= e; ey *= e; ez *= e;
v1 = new Vert( dz+ex, ey, -dx+ez);
v2 = new Vert( dz-ex, -ey, -dx-ez);
v3 = new Vert(-dz-ex, -ey, dx-ez);
v4 = new Vert(-dz+ex, ey, dx+ez);
add(V1);
}
You probably won't need this now any more, but for the sake of completeness: instead of
float py = (float) (Math.cos(ady + 1.570796327) * t);
float ny = (float) (Math.cos(ady - 1.570796327) * t);
I'd write
float py = (float) (-Math.sin(ady) * t);
float ny = (float) ( Math.sin(ady) * t);
This makes use of the fact that sin and cos differ by a phase of π/2.