I am trying to find the angle of a line in 3D space. As far as I can tell there should be two angles, one horizontal and the other vertical. In 2D coordindate system I have the following algorithm:
double x = line.getX2() - line.getX1();
double y = line.getY2() - line.getY1();
double v = y/x;
double angle = Math.atan(v);
if ( v < 0)
angle = Math.PI + angle;
if ( y < 0 )
angle = angle + Math.PI;
return angle;
But I am not sure what I would do in 3D space. Any help would be appreciated.