Example #1
0
def bevel_gears(rad1=5.0,
                n_1=15,
                t_1=2.0,
                gratio=2.0,
                hole1=False,
                hole2=False,
                twist=0.0):
    """ Beveled Gears """
    # Gear 2 radius and teeth numbers
    r_2 = gratio * rad1
    n_2 = int(gratio * n_1)

    # Calculate the thickness of gear 2, and the scaling factor
    r_2 = r_2 - t_1  # final radius of gear 2
    rad1 = (rad1 / r_2) * r_2  # final radius of gear 1
    t_2 = rad1 - rad1  # thickness of gear 2
    scaling = rad1 / rad1  # both extrusions are scaled by this factor

    g_1 = vp.shapes.gear(n=n_1, radius=rad1)
    if hole1:
        g_1 -= vp.shapes.circle(radius=rad1 / 2.)
    g_2 = vp.shapes.gear(n=n_2, radius=r_2)
    if hole2:
        g_2 -= vp.shapes.circle(radius=r_2 / 2.)

    lnp = 2
    if twist:
        lnp = 8
    cfrm = vp.frame()
    frm1 = vp.frame()
    eg1 = vp.extrusion(shape=g_1,
                       pos=vp.paths.line(start=(0, 0, 0),
                                         end=(0, 0, t_1),
                                         np=lnp),
                       scale=scaler(start=(1, 1),
                                    end=(scaling, scaling),
                                    no_p=lnp),
                       twist=-twist,
                       frame=frm1)

    frm2 = vp.frame(pos=(rad1, 0, r_2), axis=(0, 0, 1))
    eg2 = vp.extrusion(shape=g_2,
                       pos=vp.paths.line(start=(0, 0, 0),
                                         end=(0, 0, t_2),
                                         np=lnp),
                       scale=scaler(start=(1, 1),
                                    end=(scaling, scaling),
                                    no_p=lnp),
                       twist=twist / gratio,
                       frame=frm2,
                       color=vp.color.red)

    return rad1, n_1, r_2, n_2, eg1, eg2
 def __init__(self, *a):
     super().__init__(*a)
     self.curve = v.extrusion(pos=[self.pos],
                              shape=v.paths.circle(pos=(0,0), radius = 1),
                              color=(0.6, 0.4, 0),
                              scale=((0,0))
                              )
def bevel_gears(rad1=5.0, n_1=15, t_1=2.0, gratio=2.0, hole1=False, hole2=False,
                twist=0.0):
    """ Beveled Gears """
    # Gear 2 radius and teeth numbers
    r_2 = gratio*rad1
    n_2 = int(gratio*n_1)

    # Calculate the thickness of gear 2, and the scaling factor
    r_2 = r_2-t_1      # final radius of gear 2
    rad1 = (rad1/r_2)*r_2 # final radius of gear 1
    t_2 = rad1-rad1      # thickness of gear 2
    scaling = rad1/rad1 # both extrusions are scaled by this factor

    g_1 = vp.shapes.gear(n=n_1, radius=rad1)
    if hole1:
        g_1 -= vp.shapes.circle(radius=rad1/2.)
    g_2 = vp.shapes.gear(n=n_2, radius=r_2)
    if hole2:
        g_2 -= vp.shapes.circle(radius=r_2/2.)

    lnp = 2
    if twist:
        lnp = 8
    cfrm = vp.frame()
    frm1 = vp.frame()
    eg1 = vp.extrusion(
        shape=g_1, pos=vp.paths.line(
            start=(0, 0, 0),
            end=(0, 0, t_1), np=lnp),
        scale=scaler(start=(1, 1), end=(scaling, scaling), no_p=lnp),
        twist=-twist, frame=frm1)

    frm2 = vp.frame(pos=(rad1, 0, r_2), axis=(0, 0, 1))
    eg2 = vp.extrusion(shape=g_2, pos=vp.paths.line(start=(0, 0, 0), end=(0, 0, t_2), np=lnp),
                    scale=scaler(start=(1, 1), end=(scaling, scaling), no_p=lnp),
                    twist=twist/gratio, frame=frm2, color=vp.color.red)

    return rad1, n_1, r_2, n_2, eg1, eg2
Example #4
0
vp.scene.height = vp.scene.width = 800
vp.scene.center = (0.3, -2.4, 0)

def spiral(nloop=1, tightness=1.0, dirctn=1.0, scale=1.0):
    """ Draw a spiral."""
    spr = []
    scale = []
    clrs = []
    #zd = 0.01
    for turn in range(1, 1024*nloop, 16):
        turn *= 0.01
        x_val = tightness/10.0 * turn * math.cos(turn)*dirctn
        y_val = tightness/10.0 * turn * math.sin(turn)
        sc_val = math.sqrt(x_val*x_val+y_val*y_val)
        z_val = turn/7.0
        spr.append((x_val, y_val, z_val))
        clr = vp.vector((z_val*math.cos(turn), abs(math.sin(turn)),
                         abs(math.cos(turn*2)))).norm()
        clrs.append(clr)
        scale.append((sc_val, sc_val))
    return spr, scale, clrs

PATH, SCALE, CLRS = spiral(nloop=2, tightness=0.8)
ELPS = vp.shapes.circle(radius=0.69, thickness=0.01)

EE = vp.extrusion(frame=vp.frame(), shape=ELPS, pos=PATH, scale=SCALE, color=CLRS,
                  material=vp.materials.marble)
EE.frame.rotate(angle=math.pi/2)

dsk4 = extrusion(frame=eg4.frame, pos=[(0, 0, 0), (0, 0, -0.5)],
               color=eg4.color[0], shape=(shapes.circle(radius=R4+0.4) -
                shapes.circle(radius=R4/2.)))
dsk1 = extrusion(frame=eg1.frame, pos=[(0, 0, 0), (0, 0, -0.5)],
               color=eg1.color[0], shape=(shapes.circle(radius=R1+0.4) -
                shapes.circle(radius=R1/2.)))
dsk3 = extrusion(frame=eg3.frame, pos=[(0, 0, 0), (0, 0, -0.5)],
               color=eg3.color[0], shape=(shapes.circle(radius=R3+0.4) -
                shapes.circle(radius=R3/2.)))
dsk5 = extrusion(frame=eg5.frame, pos=[(0, 0, 0), (0, 0, -0.5)],
               color=eg5.color[0], shape=(shapes.circle(radius=R5+0.4) -
                shapes.circle(radius=R5/2.)))
"""

DSK6 = vp.extrusion(frame=EG6.frame, pos=[(0, 0, 0), (0, 0, -0.5)],
                    color=EG6.color[0], shape=(vp.shapes.circle(radius=R6+0.4) -
                                               vp.shapes.circle(radius=R6/2.)))

MSHAFT = vp.extrusion(
    shape=vp.shapes.ngon(np=8, radius=R5/2.), color=EG5.color[0]*0.5,
    pos=[EG5.pos[0]+vp.vector(0, 0, 1)*0.01,
         EG5.pos[0]-vp.vector(0, 0, 1)*15], frame=EG5.frame)

RAXIS = vp.extrusion(shape=vp.shapes.ngon(np=8, radius=R2/4.), color=EG2.color[0]*0.5,
                     pos=[EG2.pos[0], EG2.pos[0]-vp.vector(0, 0, 1)*15], frame=EG2.frame)
LAXIS = vp.extrusion(shape=vp.shapes.ngon(np=8, radius=R4/4.), color=EG4.color[0]*0.5,
                     pos=[EG4.pos[0], EG4.pos[0]-vp.vector(0, 0, 1)*15], frame=EG4.frame)
RFL = vp.box(pos=RAXIS.pos[-1], size=(0.2, 10, 5), color=(1, 1, 0), frame=EG2.frame)
LFL = vp.box(pos=LAXIS.pos[-1], size=(0.2, 10, 5), color=(1, 1, 0), frame=EG4.frame)

SC = vp.extrusion(shape=vp.shapes.rectangle(width=R6+1, height=R5)-vp.shapes.circle(radius=R2/3),
Example #6
0
               color=eg4.color[0], shape=(shapes.circle(radius=R4+0.4) -
                shapes.circle(radius=R4/2.)))
dsk1 = extrusion(frame=eg1.frame, pos=[(0, 0, 0), (0, 0, -0.5)],
               color=eg1.color[0], shape=(shapes.circle(radius=R1+0.4) -
                shapes.circle(radius=R1/2.)))
dsk3 = extrusion(frame=eg3.frame, pos=[(0, 0, 0), (0, 0, -0.5)],
               color=eg3.color[0], shape=(shapes.circle(radius=R3+0.4) -
                shapes.circle(radius=R3/2.)))
dsk5 = extrusion(frame=eg5.frame, pos=[(0, 0, 0), (0, 0, -0.5)],
               color=eg5.color[0], shape=(shapes.circle(radius=R5+0.4) -
                shapes.circle(radius=R5/2.)))
"""

DSK6 = vp.extrusion(frame=EG6.frame,
                    pos=[(0, 0, 0), (0, 0, -0.5)],
                    color=EG6.color[0],
                    shape=(vp.shapes.circle(radius=R6 + 0.4) -
                           vp.shapes.circle(radius=R6 / 2.)))

MSHAFT = vp.extrusion(shape=vp.shapes.ngon(np=8, radius=R5 / 2.),
                      color=EG5.color[0] * 0.5,
                      pos=[
                          EG5.pos[0] + vp.vector(0, 0, 1) * 0.01,
                          EG5.pos[0] - vp.vector(0, 0, 1) * 15
                      ],
                      frame=EG5.frame)

RAXIS = vp.extrusion(shape=vp.shapes.ngon(np=8, radius=R2 / 4.),
                     color=EG2.color[0] * 0.5,
                     pos=[EG2.pos[0], EG2.pos[0] - vp.vector(0, 0, 1) * 15],
                     frame=EG2.frame)
                   [1.00, 0.78, 0.00]], dtype=float)

# Initialize the planets.
planets = np.empty(6, sphere)
for i in range(6):
    planets[i] = sphere(pos=[planetData[i, 1], 0, 0],
                        color=(colors[i, 0], colors[i, 1], colors[i, 2]),
                        radius=c1*planetData[i, 0],
                        make_trail=True)

# Make Saturn's ring system
outer = shapes.circle(pos=(0,1.5), radius=planetData[5, 0]*c1*2)
inner = shapes.circle(pos=(0,1.5), radius=planetData[5, 0]*c1*1.3)
location = [planets[5].pos, (planets[5].pos[0], planets[5].pos[1], planets[5].pos[2]+1000)]
saturnsRings = extrusion(pos=location,
                         shape=outer-inner,
                         color=(1, 0.78, 0))


def increment_planet(p):
    """
    This function increments the position of planet p by obtaining its current
    position and then calculating its new position after taking the planet's
    orbital period into account.
    """
    x = planets[p].pos[0]  # Current x coordinate
    y = planets[p].pos[1]  # Current y coordinate
    angle = np.arctan2(y, x)
    radius = planetData[p, 1]
    period = planetData[p, 2]
    newAngle = angle + (2*np.pi)/period
Example #8
0
    # Create the ground sheet, and show a photo of the MRO as a surface texture
    ground = visual.cylinder(pos=V(0, 0, -0.2),
                             radius=20.0,
                             axis=V(0, 0, 0.2),
                             material=GMAT)

    posfile = open('aavspositions.txt', 'r')
    lines = posfile.readlines()
    bases = []
    for line in lines:  # Loop over all AAVS1.0 dipole positions
        x, y = tuple(map(float, line.split(
        )))  # Get the N/S and E/W coordinates, in meters from the centre

        # Create the base object at that position, by extruding the 2D shape (basep) up in the Z direction by 0.065m.
        b = visual.extrusion(pos=[V(x, y, 0.0), V(x, y, 0.065)],
                             shape=basep,
                             material=materials.rough,
                             color=color.gray(0.4))
        bases.append(b)

        # Create a Christmas Tree object at that position
        tree, elist = getxmas()
        tree.pos = (x, y, 0.065)
        cable = gettreecable(
            tree.pos
        )  # And add a cable tail from the Christmas Tree, pointing towards the centre

    eaxis = visual.arrow(pos=V(0, 0, 0),
                         axis=V(2, 0, 0),
                         color=color.blue,
                         shaftwidth=0.1,
                         fixedwidth=True,
Example #9
0
# We will have 24 contactor surfaces, 2 per each rotor wiring
for i in range(NS):
    # Second, subtract rectangular pieces to get a slice for each contact surface
    t = vp.shapes.rectangle(pos=(1.2 * vp.cos(i * 2 * PI / NS),
                                 1.2 * vp.sin(i * 2 * PI / NS)),
                            width=2.1,
                            height=0.05,
                            rotate=i * 2 * PI / NS)
    G1 = G1 - t

G1 = G1 - vp.shapes.circle(radius=0.5)  # Last, subtract rotor shaft
C1 = 2.0
# Now, extrude to get "cylindrical" contactor surfaces
GE1 = vp.extrusion(pos=[(0, 0, 0), (0, 0, C1)],
                   shape=G1,
                   color=(1, 0.5, 0.3),
                   material=vp.materials.rough,
                   frame=ROTOR_FRAME)

# Create contactor soldering tips, same as above
G2 = vp.shapes.circle(radius=1.4)
NS = 24
SPHS = []
for i in range(NS):
    t = vp.shapes.rectangle(pos=(1.2 * vp.cos(i * 2 * PI / NS),
                                 1.2 * vp.sin(i * 2 * PI / NS)),
                            width=2.1,
                            height=0.2,
                            rotate=i * 2 * PI / NS)
    G2 = G2 - t
    sldr = vp.sphere(frame=ROTOR_FRAME,
Example #10
0
# We will have 24 contactor surfaces, 2 per each rotor wiring
for i in range(NS):
    # Second, subtract rectangular pieces to get a slice for each contact surface
    t = vp.shapes.rectangle(
        pos=(1.2 * vp.cos(i * 2 * PI / NS), 1.2 * vp.sin(i * 2 * PI / NS)),
        width=2.1,
        height=0.05,
        rotate=i * 2 * PI / NS,
    )
    G1 = G1 - t

G1 = G1 - vp.shapes.circle(radius=0.5)  # Last, subtract rotor shaft
C1 = 2.0
# Now, extrude to get "cylindrical" contactor surfaces
GE1 = vp.extrusion(
    pos=[(0, 0, 0), (0, 0, C1)], shape=G1, color=(1, 0.5, 0.3), material=vp.materials.rough, frame=ROTOR_FRAME
)

# Create contactor soldering tips, same as above
G2 = vp.shapes.circle(radius=1.4)
NS = 24
SPHS = []
for i in range(NS):
    t = vp.shapes.rectangle(
        pos=(1.2 * vp.cos(i * 2 * PI / NS), 1.2 * vp.sin(i * 2 * PI / NS)),
        width=2.1,
        height=0.2,
        rotate=i * 2 * PI / NS,
    )
    G2 = G2 - t
    sldr = vp.sphere(
Example #11
0
def spiral(nloop=1, tightness=1.0, dirctn=1.0, scale=1.0):
    """ Draw a spiral."""
    spr = []
    scale = []
    clrs = []
    #zd = 0.01
    for turn in range(1, 1024 * nloop, 16):
        turn *= 0.01
        x_val = tightness / 10.0 * turn * math.cos(turn) * dirctn
        y_val = tightness / 10.0 * turn * math.sin(turn)
        sc_val = math.sqrt(x_val * x_val + y_val * y_val)
        z_val = turn / 7.0
        spr.append((x_val, y_val, z_val))
        clr = vp.vector((z_val * math.cos(turn), abs(math.sin(turn)),
                         abs(math.cos(turn * 2)))).norm()
        clrs.append(clr)
        scale.append((sc_val, sc_val))
    return spr, scale, clrs


PATH, SCALE, CLRS = spiral(nloop=2, tightness=0.8)
ELPS = vp.shapes.circle(radius=0.69, thickness=0.01)

EE = vp.extrusion(frame=vp.frame(),
                  shape=ELPS,
                  pos=PATH,
                  scale=SCALE,
                  color=CLRS,
                  material=vp.materials.marble)
EE.frame.rotate(angle=math.pi / 2)