Use a line that has one end point that is at the origin of the x,y, z coordinate system (0,0,0). Let the other end point of the line have any other coordinates other than the origin (0,0,0). Call the first end point the origin end point and the second end point the terminating end point.
Multiply the x coordinate of the terminating end point by itself (square it). Multiply the y coordinate of the terminating end point by itself (square it). Multiply the z-value of the terminating end point by itself (square it). Add these three results together and take the square root to find the magnitude (the length of the 3D line, also known as the magnitude of the 3D polar coordinates).
Square the x-coordinate of the terminating end point, then square the y-coordinate of the terminating end point and sum the result. Take the square root of this result. Divide the z coordinate by the last result. Now take the arctangent of this value to obtain the angle the 3D line makes with the z-axis.
Divide the y coordinate by the x coordinate of the terminating end point, and take the arctangent of the result to find the angle the 3D line makes with the X axis.
Define the equivalent 3D polar coordinates as (r, AngleZ, AngleX) where r is the magnitude of the line (its distance), AngleZ is the angle that the 3D line makes with the z-axis, and AngleX is the angle the 3D line makes with the x-axis.