(points, size_u, size_v, **kwargs)
return tuple(qtree)
Generates a quadtree-like structure from surface control points.

    This function generates a 2-dimensional list of control point coordinates. Considering the object-oriented
    representation of a quadtree data structure, first dimension of the generated list corresponds to a list of
    *QuadTree* classes. Second dimension of the generated list corresponds to a *QuadTree* data structure. The first
    element of the 2nd dimension is the mid-point of the bounding box and the remaining elements are corner points of
    the bounding box organized in counter-clockwise order.

    To maintain stability for the data structure on the edges and corners, the function accepts ``extrapolate``
    keyword argument. If it is *True*, then the function extrapolates the surface on the corners and edges to complete
    the quad-like structure for each control point. If it is *False*, no extrapolation will be applied.
    By default, ``extrapolate`` is set to *True*.

    Please note that this function's intention is not generating a real quadtree structure but reorganizing the
    control points in a very similar fashion to make them available for various geometric operations.

    :param points: 1-dimensional array of surface control points
    :type points: list, tuple
    :param size_u: number of control points on the u-direction
    :type size_u: int
    :param size_v: number of control points on the v-direction
    :type size_v: int
    :return: control points organized in a quadtree-like structure
    :rtype: tuple
Generates a quadtree-like structure from surface control points.
Generates a quadtree - like structure from surface control points .
def make_quadtree(points, size_u, size_v, **kwargs):
    """ Generates a quadtree-like structure from surface control points.

    This function generates a 2-dimensional list of control point coordinates. Considering the object-oriented
    representation of a quadtree data structure, first dimension of the generated list corresponds to a list of
    *QuadTree* classes. Second dimension of the generated list corresponds to a *QuadTree* data structure. The first
    element of the 2nd dimension is the mid-point of the bounding box and the remaining elements are corner points of
    the bounding box organized in counter-clockwise order.

    To maintain stability for the data structure on the edges and corners, the function accepts ``extrapolate``
    keyword argument. If it is *True*, then the function extrapolates the surface on the corners and edges to complete
    the quad-like structure for each control point. If it is *False*, no extrapolation will be applied.
    By default, ``extrapolate`` is set to *True*.

    Please note that this function's intention is not generating a real quadtree structure but reorganizing the
    control points in a very similar fashion to make them available for various geometric operations.

    :param points: 1-dimensional array of surface control points
    :type points: list, tuple
    :param size_u: number of control points on the u-direction
    :type size_u: int
    :param size_v: number of control points on the v-direction
    :type size_v: int
    :return: control points organized in a quadtree-like structure
    :rtype: tuple
    """
    # Get keyword arguments
    extrapolate = kwargs.get('extrapolate', True)

    # Convert control points array into 2-dimensional form
    points2d = []
    for i in range(0, size_u):
        row_list = []
        for j in range(0, size_v):
            row_list.append(points[j + (i * size_v)])
        points2d.append(row_list)

    # Traverse 2-dimensional control points to find neighbors
    qtree = []
    for u in range(size_u):
        for v in range(size_v):
            temp = [points2d[u][v]]
            # Note: negative indexing actually works in Python, so we need explicit checking
            if u + 1 < size_u:
                temp.append(points2d[u+1][v])
            else:
                if extrapolate:
                    extrapolated_edge = linalg.vector_generate(points2d[u - 1][v], points2d[u][v])
                    translated_point = linalg.point_translate(points2d[u][v], extrapolated_edge)
                    temp.append(translated_point)
            if v + 1 < size_v:
                temp.append(points2d[u][v+1])
            else:
                if extrapolate:
                    extrapolated_edge = linalg.vector_generate(points2d[u][v - 1], points2d[u][v])
                    translated_point = linalg.point_translate(points2d[u][v], extrapolated_edge)
                    temp.append(translated_point)
            if u - 1 >= 0:
                temp.append(points2d[u-1][v])
            else:
                if extrapolate:
                    extrapolated_edge = linalg.vector_generate(points2d[u + 1][v], points2d[u][v])
                    translated_point = linalg.point_translate(points2d[u][v], extrapolated_edge)
                    temp.append(translated_point)
            if v - 1 >= 0:
                temp.append(points2d[u][v-1])
            else:
                if extrapolate:
                    extrapolated_edge = linalg.vector_generate(points2d[u][v + 1], points2d[u][v])
                    translated_point = linalg.point_translate(points2d[u][v], extrapolated_edge)
                    temp.append(translated_point)
            qtree.append(tuple(temp))

    # Return generated quad-tree
    return tuple(qtree)
def make_quadtree ( points , size_u , size_v , * * kwargs ) : # Get keyword arguments extrapolate = kwargs . get ( 'extrapolate' , True ) # Convert control points array into 2-dimensional form points2d = [ ] for i in range ( 0 , size_u ) : row_list = [ ] for j in range ( 0 , size_v ) : row_list . append ( points [ j + ( i * size_v ) ] ) points2d . append ( row_list ) # Traverse 2-dimensional control points to find neighbors qtree = [ ] for u in range ( size_u ) : for v in range ( size_v ) : temp = [ points2d [ u ] [ v ] ] # Note: negative indexing actually works in Python, so we need explicit checking if u + 1 < size_u : temp . append ( points2d [ u + 1 ] [ v ] ) else : if extrapolate : extrapolated_edge = linalg . vector_generate ( points2d [ u - 1 ] [ v ] , points2d [ u ] [ v ] ) translated_point = linalg . point_translate ( points2d [ u ] [ v ] , extrapolated_edge ) temp . append ( translated_point ) if v + 1 < size_v : temp . append ( points2d [ u ] [ v + 1 ] ) else : if extrapolate : extrapolated_edge = linalg . vector_generate ( points2d [ u ] [ v - 1 ] , points2d [ u ] [ v ] ) translated_point = linalg . point_translate ( points2d [ u ] [ v ] , extrapolated_edge ) temp . append ( translated_point ) if u - 1 >= 0 : temp . append ( points2d [ u - 1 ] [ v ] ) else : if extrapolate : extrapolated_edge = linalg . vector_generate ( points2d [ u + 1 ] [ v ] , points2d [ u ] [ v ] ) translated_point = linalg . point_translate ( points2d [ u ] [ v ] , extrapolated_edge ) temp . append ( translated_point ) if v - 1 >= 0 : temp . append ( points2d [ u ] [ v - 1 ] ) else : if extrapolate : extrapolated_edge = linalg . vector_generate ( points2d [ u ] [ v + 1 ] , points2d [ u ] [ v ] ) translated_point = linalg . point_translate ( points2d [ u ] [ v ] , extrapolated_edge ) temp . append ( translated_point ) qtree . append ( tuple ( temp ) ) # Return generated quad-tree return tuple ( qtree )