当前位置: 首页>>代码示例>>Python>>正文


Python solid.translate函数代码示例

本文整理汇总了Python中solid.translate函数的典型用法代码示例。如果您正苦于以下问题:Python translate函数的具体用法?Python translate怎么用?Python translate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了translate函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: standoff

def standoff(thickness):
    """
    Stackable, gluable 3D printable standoff connector w/pivot axis.
    """
    global standnumber
    OT = (0, 0, 0)
    OQ = (0, 0, 1, 0)
    OP = (OT, OQ)
    peg_height = 5.5
    clearance = 3.2
    base = solid.cylinder(r=4, h=thickness, segments = 100)
    conn = solid.cylinder(r=1.9, h=peg_height, segments = 100)
    #wtf??? can't get z axis on Joint to work, no matter what I put it just
    #defaults to 0, so I'm going to orient everything at the origin.
    anchor = Joint((0,0, -100),Z_JOINT_POSE[1],name="A")
    b_placed = solid.translate([0,0,-thickness])(base)
    unit = b_placed+ conn - solid.translate([0,0,-(clearance+ thickness)])(conn)
    pm = PolyMesh(generator = unit)
    stand = Body(
        pose = OP,
        joints = [anchor],
        elts = [Layer(pm, name="lol", color = 'yellow')],
        name = 'standoff'+str(standnumber)
    )
    standnumber = standnumber + 1
    return stand, b_placed
开发者ID:jaywreddy,项目名称:spiderpig,代码行数:26,代码来源:main.py

示例2: strunk

def strunk():
	c1 = solid.cylinder(r= 15, h = 70)
	c2 = solid.translate([9,0,0])(solid.cylinder(r=15, h= 70))
	m1 = solid.translate([0,-15,0])(solid.cube([9,30,70]))
	total = join_list([c1,c2,m1])
	total = solid.translate([0,0,84])(total)
	return total
开发者ID:wolfram74,项目名称:march_makerness,代码行数:7,代码来源:03_12.py

示例3: locked_offset

def locked_offset():
    global locked_count
    name = "locked_" + str(locked_count)
    locked_count +=1
    j_name = "locked_joint_" + str(locked_count)
    thickness = 6 #span 2 layers
    peg_height = 3.2
    clearance = 3.2
    base = solid.cylinder(r=1.9, h=thickness, segments = 100)
    conn1 = solid.cube([4/math.sqrt(2),4/math.sqrt(2),3],center=True)
    conn2 = solid.cube([4/math.sqrt(2),4/math.sqrt(2),3],center=True)
    #wtf??? can't get z axis on Joint to work, no matter what I put it just
    #defaults to 0, so I'm going to orient everything at the origin.
    b_placed = solid.translate([0,0,3])(base)
    unit = b_placed + solid.translate([0,0,1.5])(conn1) + solid.translate([0,0,10.5])(conn2)
    pm = PolyMesh(generator = unit)
    pm.save("lock.stl")
    j1 = Joint(
        ((0, 0, 12),NZ_JOINT_POSE[1]), #9
        name=j_name
    )

    OT = (0, 0, 0)
    OQ = (0, 0, 1, 0)
    OP = (OT, OQ)

    layers=Layer(
        pm,
        name="lol",
        color='blue'
    )
    b = Body(pose=OP, elts=[layers],
                     joints=[j1], name=name)
    return b, name, j_name
开发者ID:jaywreddy,项目名称:spiderpig,代码行数:34,代码来源:linkage_solver.py

示例4: spacerMaker

def spacerMaker(radius, right, out, spacer, name):
  s = solid.rotate(a = [-90, 0, 0])\
    (solid.cylinder(r=outerD/2, h=spacer, segments = 20))


  s1 = solid.rotate(a = [90, 0, 0])\
    (solid.cylinder(r=innerD/2, h=3*spacer, segments = 20, center=True))
  s = solid.difference()(s, s1)

  """s1 = solid.rotate(a = [90, 0, 0])\
    (solid.cylinder(r=innerD/2, h=2*border, segments = 20))
  s1 = solid.translate(v = [0, spacer+2*border, 0])(s1)
  s = s + s1"""

  if not out:
    s = solid.translate(v = [0, -spacer, 0])(s)
    off = radius - width
  else:
    off = radius
  s = solid.translate(v = [0, off, 0])(s)

  if right:
    s = solid.rotate(a = [0, 0, -90])(s)
  s = PolyMesh(generator=s)
  s.save("heliodon/spacer" + name +".stl")
  return s
开发者ID:caseycrogers,项目名称:caseyluis194,代码行数:26,代码来源:heliodon_maker.py

示例5: connector

def connector():
    """
    Connector 2.0!!! comes in two better sized segments, now with indent!

    """
    global pinnumber
    OT = (0, 0, 0)
    OQ = (0, 0, 1, 0)
    OP = (OT, OQ)
    base = solid.cylinder(r=4, h = 4, segments = 100)
    conn = solid.cylinder(r = 1.9, h = 8, segments = 100 )

    #8.2
    anchor = Joint(
            ((0, 0, 8),Z_JOINT_POSE[1]),
            name="pin"
        )
    bottom = base+ solid.translate([0,0,4])(conn)
    cap = solid.translate([0,0,4+6.4])(base)
    dimple_cap  = cap - bottom

    p1 = PolyMesh(generator = bottom)
    p2 = PolyMesh(generator  = dimple_cap)
    #p1.save("pin.stl")
    #p2.save("cap.stl")
    poly = p1+p2
    pin = Body(
         pose = OP,
         joints = [anchor],
         elts = [Layer(poly, name='lol', color = 'blue')],
         name = 'coupler'+str(pinnumber)
    )
    pinnumber = pinnumber + 1
    return pin
开发者ID:jaywreddy,项目名称:spiderpig,代码行数:34,代码来源:linkage_solver.py

示例6: sarms

def sarms():
	hand = solid.sphere(r=4)
	arm = solid.translate([0,0,4])( solid.cylinder(r=4, h = 68))
	shoulder = solid.translate([0,0,72])( solid.sphere(r=4))
	a1 = hand+arm+shoulder
	a2 = solid.translate([50,0,70])(a1)
	a1 = solid.translate([-40,0,70])(a1)
	a1 = solid.rotate([0,10,0])(a1)
	a2 = solid.rotate([0,-10,0])(a2)
	return a1+a2
开发者ID:wolfram74,项目名称:march_makerness,代码行数:10,代码来源:03_12.py

示例7: ssupport

def ssupport():
	arch1 ,thet1, rad1= circle_arch(30.0, 5.0, 3)
	arch1 = solid.translate([14,-28/2,0])(solid.rotate([0,0, -thet1/2])(arch1))
	arch2 = solid.translate([0,0,1])(arch1)
	arch3 = solid.translate([0,0,-1])(arch1)
	arch1 = join_list([arch1, arch2, arch3])
	
	pillar1 = solid.rotate([0,90,0])(solid.cylinder(r=2, h=35) )
	pillar1 = pillar1 - solid.translate([-1,0,-3])(solid.cube([37,4, 8]))
	pillar2 = solid.rotate([180,0,0])(solid.translate([0,28])(pillar1))
	return join_list([arch1, pillar1, pillar2])
开发者ID:wolfram74,项目名称:march_makerness,代码行数:11,代码来源:03_03.py

示例8: create_shaft_connector

def create_shaft_connector():
    """
    Oriented relative to the shaft that will be driven at the origin in
    the +Z direction.

    TODO: Consider refactoring into mechanism with joint at O.
    """
    mount_plate = solid.cylinder(r = 10, h= 3)
    shaft = solid.translate([-2,-2,0])(solid.cube([4,4,20]))
    shifted_shaft = solid.translate([0,0,3])(shaft)
    total = mount_plate+shaft
    pl = PolyMesh(generator=total)
    return pl
开发者ID:jaywreddy,项目名称:spiderpig,代码行数:13,代码来源:main.py

示例9: plane_make_part3D

def plane_make_part3D(self, thepart, pconfig):
	self.generate_part3D(thepart, pconfig)
#	for cutout in thepart.cutouts3D:
#		for c in cutout:
#			thepart.border3D = thepart.border3D - c
	subparts = []
	for sp in thepart.parts:
		if hasattr(sp, 'subpart') and sp.subpart:
			self.make_part3D(sp, pconfig)
			if hasattr(sp, 'border3D'):
				subparts.append(sp.border3D)
	if len(subparts):
		if hasattr(thepart, 'border3D'):
			thepart.border3D=solid.union()(thepart.border3D,*subparts)
		else:
			thepart.border3D=solid.union()(*subparts)
	if not hasattr(thepart, 'border3D'):
		return False
	cutouts = [thepart.border3D]
	for cutout in thepart.cutouts3D:
		for c in cutout:
			cutouts.append(c)

	thepart.border3D = solid.difference()(*cutouts)
	# 3D transformations can only be applied to parts, so we can just go up the tree
	p = thepart
	c=0
	print p
	while(p and type(p) is not Plane):# and (c==0 or not p.renderable() )):
		p.rotations_to_3D()
		if hasattr(p, 'transform') and p.transform is not None and p.transform is not False:
			print p.transform
			if 'matrix3D' in p.transform:
				if type(p.transform['matrix3D'][0]) is list or type(p.transform['matrix3D'][0]) is Vec:
                                        thepart.border3D=solid.translate([-p.transform['matrix3D'][0][0], -p.transform['matrix3D'][0][1],-p.transform['matrix3D'][0][2]])(thepart.border3D)
					thepart.border3D=solid.multmatrix(m=p.transform['matrix3D'][1])(thepart.border3D)
					thepart.border3D=solid.translate([p.transform['matrix3D'][0][0], p.transform['matrix3D'][0][1],p.transform['matrix3D'][0][2]])(thepart.border3D)
				else:
					thepart.border3D=solid.multmatrix(m=p.transform['matrix3D'])(thepart.border3D)

			if 'rotate3D' in p.transform: 
				if type(p.transform['rotate3D'][0]) is list or type(p.transform['rotate3D'][0]) is Vec:
					thepart.border3D=solid.translate([-p.transform['rotate3D'][0][0], -p.transform['rotate3D'][0][1],-p.transform['rotate3D'][0][2]])(thepart.border3D)
					thepart.border3D=solid.rotate([p.transform['rotate3D'][1][0], p.transform['rotate3D'][1][1],p.transform['rotate3D'][1][2] ])(thepart.border3D)
					thepart.border3D=solid.translate([p.transform['rotate3D'][0][0], p.transform['rotate3D'][0][1],p.transform['rotate3D'][0][2]])(thepart.border3D)
				else:
					thepart.border3D=solid.rotate([p.transform['rotate3D'][0], p.transform['rotate3D'][1],p.transform['rotate3D'][2] ])(thepart.border3D)
			if 'translate3D' in p.transform:
				thepart.border3D=solid.translate([p.transform['translate3D'][0], p.transform['translate3D'][1],p.transform['translate3D'][2] ])(thepart.border3D)
		c+=1
		p=p.parent
开发者ID:daveansell,项目名称:camcam,代码行数:51,代码来源:cc3d.py

示例10: scaffold

def scaffold(length, color=[0, 0, 1, 1]):
    h = solid.translate([diameter / 2.0, 0, length / 2.0])(
        solid.scale([diameter, diameter, length])(
            solid.cube(center=True)
            )
    ) + solid.translate([0, 0, length / 2.0])(
        solid.scale([center_notch + tool_radius * 2,
                     center_notch, length])(
            solid.cube(center=True)
            )
    )
    # scale & move in Z to ensure overlap
    h = solid.translate([0, 0, -(length * .1)/2.0])(solid.scale([1, 1, 1.1])(h))
    return solid.color(color)(h)
开发者ID:ForgemAR,项目名称:rocket-tip-creation,代码行数:14,代码来源:base.py

示例11: rasp_pi

def rasp_pi():
	base = solid.color([0,.7,.1])(solid.cube([8.5,5.5,.1]))
	metal = t55_to_1([209,209,209])
	yellow = t55_to_1([255, 188, 60])

	ether = solid.translate([-0.1,3.9,0])(solid.cube([2.1,1.6,1.4]))
	ether = solid.color(metal)(ether)

	usb = solid.cube([1.7,1.3,1.5])
	usb = solid.translate([-.7,1.9,0])(solid.color(metal)(usb))
	
	audio = solid.cube([1.2, 1.5, 1.2])
	audio = solid.translate([1.5,-.5,0])(solid.color([0,0,0])(audio))
	
	tv = solid.cube([1,1.9,1.5])
	tv = solid.translate([3.4,-.8,0])(solid.color(yellow)(tv))	
	
	hdmi = solid.cube([1.5,1.1,.9])
	hdmi = solid.translate([3.4,4.6,0])(solid.color(metal)(hdmi))
	
	gpio = solid.cube([3.2,.4,1.2])
	gpio = solid.translate([5.3,.1,0])(solid.color([0,0,0])(gpio))
	
	sdcard = solid.cube([1.8,2.9,.4])
	sdcard = solid.translate([6.7, 1.6, -.4])(solid.color([0,0,0])(sdcard))
	
	musb = solid.cube([.5,.7,.3])
	musb = solid.translate([7.9, 4.5, 0])(solid.color([0,0,0])(musb))
	
	out = [base, ether, usb, audio, tv, hdmi, gpio, sdcard, musb]
	return join_list(out)
开发者ID:wolfram74,项目名称:march_makerness,代码行数:31,代码来源:03_12.py

示例12: genAsOpenscad

	def genAsOpenscad(self):
		
		"""Generates zebrafish geometry as solid python object.
		
		Useful if geometry is used to be passed to openscad.
		
		Returns:
			solid.solidpython.openscad_object: Solid python object. 
		
		"""
		
		outerBall=solid.translate([self.center[0],self.center[1],-self.outerRadius])(solid.sphere(r=self.outerRadius))
		innerBall=solid.translate([self.center[0],self.center[1],-self.outerRadius-self.centerDist])(solid.sphere(r=self.innerRadius))
	
		return outerBall-innerBall
开发者ID:alexblaessle,项目名称:PyFRAP,代码行数:15,代码来源:pyfrp_geometry.py

示例13: planar_slice_3d

def planar_slice_3d(mesh, slice_args, slice_width=1):
    (plane, offset) = slice_args
    slice_gen = sl.linear_extrude(slice_width)(plane.get_generator())
    slice_gen = sl.translate(offset)(slice_gen)
    slice = PolyMesh(generator=slice_gen)
    intersection = slice.intersected(mesh)
    return intersection
开发者ID:jaywreddy,项目名称:spiderpig,代码行数:7,代码来源:solution.py

示例14: assemble_chair

def assemble_chair(polygons, tf_xyz_rpy, t=3.0):
    """ Create a 3D rendering of a chair from part outlines.

    Args:
      polygons ([PolyLine]): list of PolyLines representing the outlines of the chair parts
      tf_xyz_rpy ([[x,y,z][r,p,y]]): List of transformations as x,y,z offsets and roll, pitch,
        yaw rotations in degrees

      t (int): material thickness

    Returns:
      A list of PolyMeshes, with one PolyMesh per input polygon, transformed by corresponding
      tf input

    """
    polys = []
    for (p, r) in zip(polygons, tf_xyz_rpy):
        translation, rotation = r
        solid_p = p.get_generator()
        thick_p = sl.linear_extrude(t)(solid_p)
        rotated_p = sl.rotate(rotation)(thick_p)
        translated_p = sl.translate(translation)(rotated_p)
        poly = PolyMesh(generator=translated_p)
        polys.append(poly)
    return polys
开发者ID:jaywreddy,项目名称:spiderpig,代码行数:25,代码来源:solution.py

示例15: viz

  def viz(self,position):
    """
    Generates a OpenScad model to visualize the sun position
    """

    ## Generating the hemisphere ##
    starting_sphere = solid.sphere(self.r, segments= 64)
    box_sub = solid.utils.down(((self.r * 2 + 10)/2))(solid.cube((self.r * 2 + 10), center= True))
    hemisphere = starting_sphere - box_sub
    hemisphere = PolyMesh(generator= hemisphere).simplified()
    #hemisphere = (solid.utils.color([0.75,0.75,0.75,0.1]))(hemisphere.get_generator()) #this sucks...need to do this way in order do render
    #hemisphere = PolyMesh(generator= hemisphere)

    ## Generate the sphere for the sun ##
    sun_sphere = solid.sphere(5, segments= 64)
    vector = position
    sun_sphere = (solid.translate(vector))(sun_sphere)
    sun_sphere = PolyMesh(generator= sun_sphere).simplified()

    L1 = Layer(hemisphere, name= "hem", color=[200,200,200,1000])
    L2 = Layer(sun_sphere, name="sun", color='yellow')

    B1 = Block([L1, L2])

    return B1.show(is_2d= False)

    
开发者ID:caseycrogers,项目名称:caseyluis194,代码行数:25,代码来源:sunposition.py


注:本文中的solid.translate函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。