def ortho_basis(normal, ref_vec=None):
    import numpy as np
    from scipy import linalg as spla
    from scipy import random as sprnd
    from ..const import PRM
    from ..error import VectorError
    RAND_MAG = 0.25
    if not len(normal.shape) == 1:
        raise ValueError("'normal' is not a vector")
    if not normal.shape[0] == 3:
        raise ValueError("Length of 'normal' is not three")
    nv = normal / spla.norm(normal)
    if ref_vec is None:
        rv = nv
        while parallel_check(nv, rv):
            rv = np.float64(1.0 - RAND_MAG + 2 * RAND_MAG * sprnd.rand(3))
        rv = rej(rv, nv)
        rv = rv / spla.norm(rv)
    else:
        if not len(ref_vec.shape) == 1:
            raise ValueError("ref_vec is not a vector")
        if not ref_vec.shape[0] == 3:
            raise ValueError("ref_vec length is not three")
        rv = ref_vec / spla.norm(ref_vec)
        if parallel_check(nv, rv):
            raise VectorError(VectorError.NONPRL,
                    "'normal' and 'ref_vec' are too nearly parallel.", "")
    on2 = np.cross(nv, rv)
    on2 = on2 / spla.norm(on2)
    on1 = np.cross(on2, nv)
    on1 = on1 / spla.norm(on1)
    return on1, on2