本文整理汇总了Python中Mesh.createCylinder方法的典型用法代码示例。如果您正苦于以下问题:Python Mesh.createCylinder方法的具体用法?Python Mesh.createCylinder怎么用?Python Mesh.createCylinder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mesh
的用法示例。
在下文中一共展示了Mesh.createCylinder方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _createCylinder
# 需要导入模块: import Mesh [as 别名]
# 或者: from Mesh import createCylinder [as 别名]
def _createCylinder(proxy, axis, basePos, tipPos, radius, colour, moiScale, withMesh):
"""
Private function.
Use createCylinder() or createArticulatedCylinder() instead.
"""
if axis != 0 and axis != 1 and axis != 2:
raise ValueError("Axis must be 0 for x, 1 for y or 2 for z.")
# Mesh and cdps will be set manually
proxy.meshes = None
proxy.cdps = None
# Compute box moi
moi = [0, 0, 0]
height = math.fabs(tipPos - basePos)
for i in range(3):
if i == axis:
moi[i] = proxy.mass * radius * radius / 2.0
else:
moi[i] = proxy.mass * (3 * radius * radius + height * height) / 12.0
### HACK!
moi[i] = max(moi[i], 0.01)
proxy.moi = PyUtils.toVector3d(moi) * moiScale
cylinder = proxy.createAndFillObject()
basePoint = [0, 0, 0]
tipPoint = [0, 0, 0]
basePoint[axis] = basePos
tipPoint[axis] = tipPos
basePoint3d = PyUtils.toPoint3d(basePoint)
tipPoint3d = PyUtils.toPoint3d(tipPoint)
baseToTipVector3d = Vector3d(basePoint3d, tipPoint3d)
if baseToTipVector3d.isZeroVector():
raise ValueError("Invalid points for cylinder: base and tip are equal!")
baseToTipUnitVector3d = baseToTipVector3d.unit()
if height <= radius * 2.0:
cdp = Physics.SphereCDP()
cdp.setCenter(basePoint3d + baseToTipVector3d * 0.5)
cdp.setRadius(height / 2.0)
else:
cdp = Physics.CapsuleCDP()
cdp.setPoint1(basePoint3d + baseToTipUnitVector3d * radius)
cdp.setPoint2(tipPoint3d + baseToTipUnitVector3d * -radius)
cdp.setRadius(radius)
cylinder.addCollisionDetectionPrimitive(cdp)
if withMesh:
mesh = Mesh.createCylinder(basePoint, tipPoint, radius, colour)
cylinder.addMesh(mesh)
return cylinder
示例2: createConicalFrustum
# 需要导入模块: import Mesh [as 别名]
# 或者: from Mesh import createCylinder [as 别名]
def createConicalFrustum(radius1, radius2, height, pnt=FreeCAD.Vector(), fn=50):
if fuzzyCompare(radius1, radius2):
mesh = Mesh.createCylinder(abs(radius1), abs(height), 1, 0.5/fn, int(fn))
mesh.transform(FreeCAD.Placement(pnt, FreeCAD.Rotation(0,-90,0)).toMatrix())
return mesh
elif radius1*radius2 >= 0:
mesh = Mesh.createCone(abs(radius1), abs(radius2), abs(height), 1, 0.5/fn, int(fn))
mesh.transform(FreeCAD.Placement(pnt, FreeCAD.Rotation(0,-90,0)).toMatrix())
return mesh
else:
height1 = abs(height)*abs(radius1/(radius1-radius2))
height2 = abs(height)*abs(radius2/(radius1-radius2))
pnt1 = pnt
pnt2 = pnt + FreeCAD.Vector(0, 0, height1)
mesh1 = Mesh.createCone(abs(radius1), 0, height1, 1, 0.5/fn, int(fn))
mesh1.transform(FreeCAD.Placement(pnt1, FreeCAD.Rotation(0,-90,0)).toMatrix())
mesh2 = Mesh.createCone(0, abs(radius2), height2, 1, 0.5/fn, int(fn))
mesh2.transform(FreeCAD.Placement(pnt2, FreeCAD.Rotation(0,-90,0)).toMatrix())
mesh = mesh1.unite(mesh2)
return mesh