How to use the clifford.MVArray function in clifford

To help you get started, we’ve selected a few clifford examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pygae / clifford / clifford / tools / g3c / __init__.py View on Github external
def midpoint_of_line_cluster(line_cluster):
    """
    Gets a center point of a line cluster
    Hadfield and Lasenby AGACSE2018
    """
    return layout.MultiVector(val_midpoint_of_line_cluster(MVArray(line_cluster).value))
github pygae / clifford / clifford / tools / g3c / GAOnline.py View on Github external
def draw_objects(objects, mv_type='interp', color='rgb(0,0,0)', print_scene=True):
    """
    Takes a list of multivectors or a .ga file name and draws the multivectors
    By default attempts to interpret the type of object unless a mv_type is specified
    """
    if isinstance(objects, str):
        data_array, metric, basis_names, support = read_ga_file(objects)
        mv_list = [layout.MultiVector(data_array[i, :]) for i in range(data_array.shape[0])]
        sc = GAScene()
        sc.add_object_array(mv_list, mv_type, color=color)
        if print_scene:
            print(sc)
        return sc
    elif isinstance(objects, list) or isinstance(objects, MVArray):
        sc = GAScene()
        sc.add_object_array(objects, mv_type, color=color)
        if print_scene:
            print(sc)
        return sc
    else:
        raise ValueError('The input is not a string or a list of objects')
github pygae / clifford / clifford / tools / point_processing.py View on Github external
def conformal_rounds(self):
        """
        Returns the conformal rounds made of the wedge
        product of the edge simplices
        """
        if isinstance(self.layout, ConformalLayout):
            return [MVArray([self.GApoints[i] for i in s]).op().normal() for s in self.simplices]
        else:
            raise ValueError('Input points do not seem to be from a conformal algebra')
github pygae / clifford / clifford / tools / g3c / cost_functions.py View on Github external
def object_set_cost_matrix(object_set_a, object_set_b,
                           object_type="generic", symmetric=False):
    """
    Evaluates the rotor cost matrix between two sets of objects
    """
    object_array_a = MVArray(object_set_a).value
    object_array_b = MVArray(object_set_b).value
    if object_type == 'lines':
        ret_mat = val_line_set_cost_matrix(object_array_a, object_array_b)
        if symmetric:
            ret_mat = np.minimum(ret_mat, val_line_set_cost_matrix(object_array_a, -object_array_b))
        return ret_mat
    else:
        ret_mat = val_object_set_cost_matrix(object_array_a, object_array_b)
        if symmetric:
            ret_mat = np.minimum(ret_mat, val_object_set_cost_matrix(object_array_a, -object_array_b))
        return ret_mat
github pygae / clifford / clifford / _multivector.py View on Github external
def __array__(self) -> 'cf.MVArray':
        # we are a scalar, and the only appropriate dtype is an object array
        return cf.MVArray([self])
github pygae / clifford / clifford / tools / g3c / cost_functions.py View on Github external
def object_set_cost_matrix(object_set_a, object_set_b,
                           object_type="generic", symmetric=False):
    """
    Evaluates the rotor cost matrix between two sets of objects
    """
    object_array_a = MVArray(object_set_a).value
    object_array_b = MVArray(object_set_b).value
    if object_type == 'lines':
        ret_mat = val_line_set_cost_matrix(object_array_a, object_array_b)
        if symmetric:
            ret_mat = np.minimum(ret_mat, val_line_set_cost_matrix(object_array_a, -object_array_b))
        return ret_mat
    else:
        ret_mat = val_object_set_cost_matrix(object_array_a, object_array_b)
        if symmetric:
            ret_mat = np.minimum(ret_mat, val_object_set_cost_matrix(object_array_a, -object_array_b))
        return ret_mat
github pygae / clifford / clifford / tools / g3c / __init__.py View on Github external
def general_object_interpolation(object_alpha_array, object_list, new_alpha_array, kind='linear'):
    """
    Hadfield and Lasenby, Direct Linear Interpolation of Geometric Objects, AGACSE2018
    This is a general interpolation through the
    """
    obj_array = np.transpose(MVArray(object_list).value)
    f = interp1d(object_alpha_array, obj_array, kind=kind)
    new_value_array = np.transpose(f(new_alpha_array))
    new_conf_array = MVArray.from_value_array(layout, new_value_array)
    return [neg_twiddle_root(C)[0].normal() for C in new_conf_array]