Beispiel #1
0
def circle(hl, startcoor, endcoor):
    r = math.sqrt(
        pow(startcoor[0] - endcoor[0], 2) + pow(startcoor[1] - endcoor[1], 2) +
        pow(startcoor[2] - endcoor[2], 2))
    theta = math.atan2(
        endcoor[2] - startcoor[2],
        math.sqrt(
            pow(startcoor[0] - endcoor[0], 2) +
            pow(startcoor[1] - endcoor[1], 2)))
    psi = math.atan2(endcoor[1] - startcoor[1], endcoor[0] - startcoor[0])
    for i in range(N + 1):
        update_fig(hl, [
            r * (np.cos(
                (i / N) * 2 * np.pi) * np.cos(theta) * np.cos(psi) - np.sin(
                    (i / N) * 2 * np.pi) * np.sin(psi)) + startcoor[0], r *
            (np.cos(
                (i / N) * 2 * np.pi) * np.cos(theta) * np.sin(psi) + np.sin(
                    (i / N) * 2 * np.pi) * np.cos(psi)) + startcoor[1],
            r * np.cos((i / N) * 2 * np.pi) * np.sin(theta) + startcoor[2]
        ])
    return hl
Beispiel #2
0
def cube(hl, startcoor, endcoor):
    print(hl)
    update_fig(hl, startcoor)
    update_fig(hl, [startcoor[0], endcoor[1], startcoor[2]])
    update_fig(hl, [endcoor[0], endcoor[1], startcoor[2]])
    update_fig(hl, [endcoor[0], startcoor[1], startcoor[2]])
    update_fig(hl, startcoor)
    update_fig(hl, [startcoor[0], startcoor[1], endcoor[2]])
    update_fig(hl, [startcoor[0], endcoor[1], endcoor[2]])
    update_fig(hl, [startcoor[0], endcoor[1], startcoor[2]])
    update_fig(hl, [startcoor[0], endcoor[1], endcoor[2]])
    update_fig(hl, [endcoor[0], endcoor[1], endcoor[2]])
    update_fig(hl, [endcoor[0], endcoor[1], startcoor[2]])
    update_fig(hl, [endcoor[0], endcoor[1], endcoor[2]])
    update_fig(hl, [endcoor[0], startcoor[1], endcoor[2]])
    update_fig(hl, [endcoor[0], startcoor[1], startcoor[2]])
    update_fig(hl, [endcoor[0], startcoor[1], endcoor[2]])
    update_fig(hl, [startcoor[0], startcoor[1], endcoor[2]])
    return hl
Beispiel #3
0
def line(hl, startcoor, endcoor):
    update_fig(hl, startcoor)
    update_fig(hl, endcoor)
    return hl
Beispiel #4
0
def colored_rect(hl, startcoor, endcoor):
    rect_x = endcoor[0] - startcoor[0]
    rect_y = endcoor[1] - startcoor[1]
    rect_z = endcoor[2] - startcoor[2]
    min(rect_x, rect_y, rect_z)
    if ((rect_x < rect_y) and (rect_x < rect_z)):
        for i in range(N):
            update_fig(hl, [
                startcoor[0], ((N - i) / N) * startcoor[1] +
                (i / N) * endcoor[1], startcoor[2]
            ])
            update_fig(hl, [
                startcoor[0],
                ((N - i) / N) * startcoor[1] + (i / N) * endcoor[1], endcoor[2]
            ])
            update_fig(hl, [startcoor[0], startcoor[1], endcoor[2]])
            update_fig(hl, startcoor)

    elif ((rect_y < rect_x) and (rect_y < rect_z)):
        for i in range(N):
            update_fig(hl, [endcoor[0], startcoor[1], startcoor[2]])
            update_fig(hl, [
                endcoor[0], startcoor[1],
                ((N - i) / N) * startcoor[2] + (i / N) * endcoor[2]
            ])
            update_fig(hl, [
                startcoor[0], startcoor[1],
                ((N - i) / N) * startcoor[2] + (i / N) * endcoor[2]
            ])
            update_fig(hl, startcoor)
    elif ((rect_z < rect_y) and (rect_z < rect_x)):
        for i in range(N):
            update_fig(hl, [startcoor[0], endcoor[1], startcoor[2]])
            update_fig(hl, [((N - i) / N) * startcoor[0] +
                            (i / N) * endcoor[0], endcoor[1], startcoor[2]])
            update_fig(hl, [((N - i) / N) * startcoor[0] +
                            (i / N) * endcoor[0], startcoor[1], startcoor[2]])
            update_fig(hl, startcoor)
    else:
        for i in range(N):
            update_fig(hl, [startcoor[0], endcoor[1], startcoor[2]])
            update_fig(hl, [((N - i) / N) * startcoor[0] +
                            (i / N) * endcoor[0], endcoor[1], startcoor[2]])
            update_fig(hl, [((N - i) / N) * startcoor[0] +
                            (i / N) * endcoor[0], startcoor[1], startcoor[2]])
            update_fig(hl, startcoor)
        #print("error!")
    return hl
Beispiel #5
0
def rect(hl, startcoor, endcoor):
    rect_x = endcoor[0] - startcoor[0]
    rect_y = endcoor[1] - startcoor[1]
    rect_z = endcoor[2] - startcoor[2]
    min(rect_x, rect_y, rect_z)
    if ((rect_x < rect_y) and (rect_x < rect_z)):
        update_fig(hl, [startcoor[0], endcoor[1], startcoor[2]])
        update_fig(hl, [startcoor[0], endcoor[1], endcoor[2]])
        update_fig(hl, [startcoor[0], startcoor[1], endcoor[2]])
        update_fig(hl, startcoor)
    elif ((rect_y < rect_x) and (rect_y < rect_z)):
        update_fig(hl, [endcoor[0], startcoor[1], startcoor[2]])
        update_fig(hl, [endcoor[0], startcoor[1], endcoor[2]])
        update_fig(hl, [startcoor[0], startcoor[1], endcoor[2]])
        update_fig(hl, startcoor)
    elif ((rect_z < rect_y) and (rect_z < rect_x)):
        update_fig(hl, [startcoor[0], endcoor[1], startcoor[2]])
        update_fig(hl, [endcoor[0], endcoor[1], startcoor[2]])
        update_fig(hl, [endcoor[0], startcoor[1], startcoor[2]])
        update_fig(hl, startcoor)
    else:
        update_fig(hl, [startcoor[0], endcoor[1], startcoor[2]])
        update_fig(hl, [endcoor[0], endcoor[1], startcoor[2]])
        update_fig(hl, [endcoor[0], startcoor[1], startcoor[2]])
        update_fig(hl, startcoor)
        #print(f"error! rect_x:{rect_x}, rect_y:{rect_y}, rect_z:{rect_z}")
    return hl