def cylinder_vertices(Subd, Vertices, Height, RadiusBot, RadiusTop, Separate):
    theta = 360/Vertices
    heightSubd = Height/(Subd+1)
    X = []
    Y = []
    Z = []
    for i in range(Subd+2):
        radius = RadiusBot - ((RadiusBot-RadiusTop)/(Subd+1))*i
        for j in range(Vertices):
            X.append(radius*cos(radians(theta*j)))
            Y.append(radius*sin(radians(theta*j)))
            Z.append(heightSubd*i)

    points = list(sv_zip(X, Y, Z))
    if Separate:
        out = []
        out_ = []
        x = 0
        for y, P in enumerate(points):
            x += 1
            out_.append(P)
            if x//Vertices:
                out.append(out_)
                out_ = []
                x = 0
        points = out
        #points = list(zip(*out))
    return points
Example #2
0
def sv_main(data=[], step=0.3):

    # in boilerplate - make your own sockets
    in_sockets = [
        ['v', 'vertices', data],
        ['s', 'Step (0...3)', step],
    ]

    # import libreryes - your defined
    from sverchok.data_structure import sv_zip
    from math import sin, cos
    #from random import random
    # your's code here
    step_ = (step % 6 - 3) / 1.2
    #ran = random()

    if data:
        out_x_ = [sin(i[0] / step_) for i in data]
        out_y_ = [cos(i[0] / step_) for i in data]
        out_z = [sin(i[0] * step_) for i in data]
        out_x = [i + sin(out_x_[k]) for k, i in enumerate(out_x_)]
        out_y = [i + cos(out_y_[k]) for k, i in enumerate(out_y_)]
        out = list(sv_zip(out_x, out_y, out_z))
        edg = [[i, i - 1] for i, ed in enumerate(out_x) if i > 0]
    else:
        out_x = [i * step_ for i in range(100)]
        out_y = [cos(i * step_) for i in out_x]
        out_z = [sin(i * step_) * out_y[k] for k, i in enumerate(out_y)]
        out = list(sv_zip(out_x, out_y, out_z))
        edg = [[i, i - 1] for i, ed in enumerate(out_x) if i > 0]

    # out boilerplate - set your own sockets packet
    out_sockets = [
        ['v', 'ver', [out]],
        ['s', 'edg', [edg]],
    ]

    return in_sockets, out_sockets
Example #3
0
    def process(self):
        # return if no outputs are connected
        if not any(s.is_linked for s in self.outputs):
            return
        # input values lists
        params = [s.sv_get() for s in self.inputs]
        params = list_match_func[self.list_match_global](params)

        vert_list, edge_list, poly_list = [], [], []

        if self.flat_output:
            v_add, e_add, p_add = vert_list.extend, edge_list.extend, poly_list.extend
        else:
            v_add, e_add, p_add = vert_list.append, edge_list.append, poly_list.append

        for par in sv_zip(*params):
            verts, edges, polys = self.pentagon_tiler(par)
            v_add(verts)
            e_add(edges)
            p_add(polys)

        self.outputs['Vertices'].sv_set(vert_list)
        self.outputs['Edges'].sv_set(edge_list)
        self.outputs['Polygons'].sv_set(poly_list)