def twist_trans(tw: np.ndarray, linear: bool = False) -> tuple[np.ndarray, np.ndarray]:
    """
    Convert from twist representation to transformation matrix.

    Args:
        tw (numpy.ndarray): Twist vector.
        linear (bool, optional): Linear approximation.
    """
    if linear:
        return np.identity(3) + skew(tw[:3]), tw[3:]
    else:
        twd = np.linalg.norm(tw[:3])
        if twd == 0.0:
            return np.identity(3), tw[3:]
        else:
            ntw = tw[:3] / twd
            c = np.cos(twd)
            s = np.sin(twd)
            tr = c * np.identity(3) + (1.0 - c) * np.outer(ntw, ntw) + s * skew(ntw)
            return tr, tw[3:]

    Convert from twist representation to transformation matrix.

    Args:
        tw (numpy.ndarray): Twist vector.
        linear (bool, optional): Linear approximation.
    
probreg/se3_op.py