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


Python Mesh.createBox方法代码示例

本文整理汇总了Python中Mesh.createBox方法的典型用法代码示例。如果您正苦于以下问题:Python Mesh.createBox方法的具体用法?Python Mesh.createBox怎么用?Python Mesh.createBox使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mesh的用法示例。


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

示例1: _createBox

# 需要导入模块: import Mesh [as 别名]
# 或者: from Mesh import createBox [as 别名]
def _createBox(proxy, size, colour, moiScale, withMesh):
    """
    Private function.
    Use createBox() or createArticulatedBox() instead.
    """

    # Mesh and cdps will be set manually
    proxy.meshes = None
    proxy.cdps = None

    # Compute box moi
    size = PyUtils.toVector3d(size)
    proxy.moi = (
        MathLib.Vector3d(
            size.y * size.y + size.z * size.z, size.x * size.x + size.z * size.z, size.x * size.x + size.y * size.y
        )
        * 1.0
        / 12.0
        * proxy.mass
        * moiScale
    )

    box = proxy.createAndFillObject()

    cdp = Physics.BoxCDP()
    halfSize = PyUtils.toVector3d(size) * 0.5

    cdp.setPoint1(MathLib.Point3d(halfSize * -1))
    cdp.setPoint2(MathLib.Point3d(halfSize))

    box.addCollisionDetectionPrimitive(cdp)

    if withMesh:
        mesh = Mesh.createBox(size=size, colour=colour)
        box.addMesh(mesh)

    return box
开发者ID:Phong13,项目名称:cartwheel-3d,代码行数:39,代码来源:RigidBody.py

示例2: construct

# 需要导入模块: import Mesh [as 别名]
# 或者: from Mesh import createBox [as 别名]

#.........这里部分代码省略.........
        rot = rmat_k2d(zet.direction)
        center = zet.direction*zet.offset
        placement = spexpr2fcexpr(AffineTransformation(matrix=rot, vector=center))

        mbb_ = mbb.transformed(placement.inverse().toMatrix())
        height = mbb_.ZMax + margin
        xm = max(abs(mbb_.XMax), abs(mbb_.XMin))
        ym = max(abs(mbb_.YMax), abs(mbb_.YMin))
        radius = math.sqrt(xm**2 + ym**2) + margin
        mesh = createConicalFrustum(radius, radius, height, fn=fn)
        mesh.Placement = placement
        return mesh

    elif isinstance(zet, euclid.InfiniteCylinder):
        direction = spexpr2fcexpr(zet.direction)
        center = spexpr2fcexpr(zet.center)
        dist = mbb.Center.distanceToLine(center, direction)
        radius = spexpr2fcexpr(zet.radius)
        mbb_radius = mbb.DiagonalLength/2
        if radius + mbb_radius < dist:
            return False
        elif radius - mbb_radius > dist:
            return True

        rot = rmat_k2d(zet.direction)
        placement = spexpr2fcexpr(AffineTransformation(matrix=rot, vector=zet.center))

        mbb_ = mbb.transformed(placement.inverse().toMatrix())
        height = mbb_.ZLength + 2*margin
        bottom = FreeCAD.Vector(0, 0, mbb_.ZMin-margin)
        mesh = createConicalFrustum(radius, radius, height, bottom, fn=fn)
        mesh.Placement = placement
        return mesh

    elif isinstance(zet, euclid.SemiInfiniteCone):
        pnt = mbb.Center - spexpr2fcexpr(zet.center)
        mbb_radius = mbb.DiagonalLength/2
        if pnt.Length > mbb_radius:
            direction = spexpr2fcexpr(zet.direction)
            ang = abs(math.acos(direction*pnt/pnt.Length))
            ang_cone = math.atan(spexpr2fcexpr(zet.slope))
            ang_ball = math.asin(mbb_radius/pnt.Length)
            if ang_cone + ang_ball < ang:
                return False
            elif ang_cone - ang_ball > ang:
                return True

        rot = rmat_k2d(zet.direction)
        placement = spexpr2fcexpr(AffineTransformation(matrix=rot, vector=zet.center))

        mbb_ = mbb.transformed(placement.inverse().toMatrix())
        height = mbb_.ZLength + margin
        radius = height*spexpr2fcexpr(zet.slope)
        mesh = createConicalFrustum(0, radius, height, fn=fn)
        mesh.Placement = placement
        return mesh

    elif isinstance(zet, euclid.Sphere):
        radius = spexpr2fcexpr(zet.radius)
        mesh = Mesh.createSphere(radius, int(fn))

        placement = spexpr2fcexpr(AffineTransformation(vector=zet.center))
        mesh.Placement = placement
        return mesh

    elif isinstance(zet, euclid.Box):
        size = spexpr2fcexpr(zet.size)
        mesh = Mesh.createBox(size.x, size.y, size.z)

        rot = zet.orientation
        placement = spexpr2fcexpr(AffineTransformation(matrix=rot, vector=zet.center))
        mesh.Placement = placement

        return mesh

    elif isinstance(zet, euclid.Cylinder):
        radius = spexpr2fcexpr(zet.radius)
        height = spexpr2fcexpr(zet.height)
        pnt = FreeCAD.Vector(0, 0, -height/2)
        mesh = createConicalFrustum(radius, radius, height, pnt, fn=fn)

        rot = rmat_k2d(zet.direction)
        placement = spexpr2fcexpr(AffineTransformation(matrix=rot, vector=zet.center))
        mesh.Placement = placement

        return mesh

    elif isinstance(zet, euclid.Cone):
        radius = spexpr2fcexpr(zet.radius)
        height = spexpr2fcexpr(zet.height)
        mesh = createConicalFrustum(0, radius, height, fn=fn)

        rot = rmat_k2d(zet.direction)
        placement = spexpr2fcexpr(AffineTransformation(matrix=rot, vector=zet.center))
        mesh.Placement = placement

        return mesh

    else:
        raise TypeError
开发者ID:worldmaker18349276,项目名称:magicpy,代码行数:104,代码来源:Primitive.py

示例3: PlaceBox

# 需要导入模块: import Mesh [as 别名]
# 或者: from Mesh import createBox [as 别名]
# Script to create a Menger sponge
# (c) 2012 Werner Mayer LGPL

# The script is based on the work of daxmick at
# http://forum.freecadweb.org/viewtopic.php?f=3&t=2307

import threading
import Mesh, MeshGui
from FreeCAD import Base

# Create a global mesh and make copies of them
# This makes the algorithm faster by ~60%.
box = Mesh.createBox(1,1,1)

# Create a Box and Place it a coords (x,y,z)
def PlaceBox(x,y,z):
   global box
   mbox=box.copy()
   mbox.translate(x,y,z)
   return mbox

def Sierpinski(level,x0,y0,z0):
   #print(threading.current_thread().name)
   boxnums = pow(3,level)
   thirds = boxnums / 3
   twothirds = thirds * 2
   if(level == 0):
      rangerx = [x0]
      rangery = [y0]
      rangerz = [z0]
   else:
开发者ID:AjinkyaDahale,项目名称:FreeCAD,代码行数:33,代码来源:MengerSponge.py


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