public void projectTo(final ComplexProjective1 cp)
        throws IllegalArgumentException {
        /* Check if the point lies on the sphere. */
        if (Math.abs(normSquared() - 1.0) > EPSILON) {
            throw new IllegalArgumentException("Norm must be 1.0. " +
                                               "Norm is " + norm() + ". ");
        }
        /* Check if the point lies above or below the xy-plane. */
        if (z > 0.0) {
            /* We might be close to the north pole. This would be bad,
             * numerically. So perform a 180 degree rotation around the
             * x-axis, project that point, and swap the entries of the
             * result.
             */
            /* Dummy variables */
            final double dummyRe;
            final double dummyIm;
            /* Rotate by 180 degree around the x-axis. */
            y = -y;
            z = -z;
            /* Project that point. Now, z < -EPSILON. */
            belowXYProjectTo(cp);
            /* Rotate back. */
            y = -y;
            z = -z;
            /* Swap the entries of the result.
             *
             * TODO: Maybe Complex2 should have a final method that swaps the
             * entries. This might speed up dereferencing the fields of cp,
             * because dereferencing fiels of other objects might be slower
             * than dereferencing fields of the same object. But actually, I
             * don't know if that is true or if it matters. */
            dummyRe = cp.aRe;
            dummyIm = cp.aIm;
            cp.aRe = cp.bRe;
            cp.aIm = cp.bIm;
            cp.bRe = dummyRe;
            cp.bIm = dummyIm;
        } else {
            /* Point lies below xy-plane so we use */
            belowXYProjectTo(cp);
        }
    }
public void projectTo(final ComplexProjective1 cp)
        throws IllegalArgumentException {
       
        if (Math.abs(normSquared() - 1.0) > EPSILON) {
            throw new IllegalArgumentException("Norm must be 1.0. " +
                                               "Norm is " + norm() + ". ");
        }
       
        if (z > 0.0) {
           
           
            final double dummyRe;
            final double dummyIm;
           
            y = -y;
            z = -z;
           
            belowXYProjectTo(cp);
           
            y = -y;
            z = -z;
           
            dummyRe = cp.aRe;
            dummyIm = cp.aIm;
            cp.aRe = cp.bRe;
            cp.aIm = cp.bIm;
            cp.bRe = dummyRe;
            cp.bIm = dummyIm;
        } else {
           
            belowXYProjectTo(cp);
        }
    }
public void projectto(final complexprojective1 cp) throws illegalargumentexception { if (math.abs(normsquared() - 1.0) > epsilon) { throw new illegalargumentexception("norm must be 1.0. " + "norm is " + norm() + ". "); } if (z > 0.0) { final double dummyre; final double dummyim; y = -y; z = -z; belowxyprojectto(cp); y = -y; z = -z; dummyre = cp.are; dummyim = cp.aim; cp.are = cp.bre; cp.aim = cp.bim; cp.bre = dummyre; cp.bim = dummyim; } else { belowxyprojectto(cp); } }