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


Python FreeCAD.Matrix方法代码示例

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


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

示例1: getElementPlacement

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import Matrix [as 别名]
def getElementPlacement(obj,mat=None):
    '''Get the placement of an element

       obj: either a document object or a tuple(obj,subname)
       mat: if not None, then this should be a matrix, and the returned
            placement will be relative to this transformation matrix.
    '''
    if not isElement(obj):
        if not isinstance(obj,(tuple,list)):
            pla = obj.Placement
        else:
            _,mat = obj[0].getSubObject(obj[1],1,FreeCAD.Matrix())
            pla = FreeCAD.Placement(mat)
    else:
        pla = FreeCAD.Placement(getElementPos(obj),getElementRotation(obj))
    if not mat:
        return pla
    return FreeCAD.Placement(mat.inverse()).multiply(pla) 
开发者ID:realthunder,项目名称:FreeCAD_assembly3,代码行数:20,代码来源:utils.py

示例2: helicalextrusion

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import Matrix [as 别名]
def helicalextrusion(wire, height, angle, double_helix=False):
    direction = bool(angle < 0)
    if double_helix:
        first_spine = makeHelix(height * 2. * np.pi /
                                abs(angle), 0.5 * height, 10., 0, direction)
        first_solid = first_spine.makePipeShell([wire], True, True)
        second_solid = first_solid.mirror(
            fcvec([0., 0., 0.]), fcvec([0, 0, 1]))
        faces = first_solid.Faces + second_solid.Faces
        faces = [f for f in faces if not on_mirror_plane(
            f, 0., fcvec([0., 0., 1.]))]
        solid = makeSolid(makeShell(faces))
        mat = App.Matrix()
        mat.move(fcvec([0, 0, 0.5 * height]))
        return solid.transformGeometry(mat)
    else:
        first_spine = makeHelix(height * 2 * np.pi /
                                abs(angle), height, 10., 0, direction)
        first_solid = first_spine.makePipeShell([wire], True, True)
        return first_solid 
开发者ID:looooo,项目名称:freecad.gears,代码行数:22,代码来源:features.py

示例3: execute

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import Matrix [as 别名]
def execute(self,obj):
		sayd("execute _Plugger")
		self.obj2.status=0
		obj.end=obj.start+obj.duration
		if self.obj2.trafoMode == "yz":
			self.obj2.trafoMatrix=FreeCAD.Matrix(
				0,0,0,0,
				1,0,0,0,
				0,1,0,0,
				0,0,0,1);
		if self.obj2.trafoMode == "xz":
			self.obj2.trafoMatrix=FreeCAD.Matrix(
				1,0,0,0,
				0,0,0,0,
				0,1,0,0,
				0,0,0,1);
		obj.setEditorMode("end", 1) #ro 
开发者ID:microelly2,项目名称:Animation,代码行数:19,代码来源:Animation.py

示例4: get_transformation_matrix_from_vectors

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import Matrix [as 别名]
def get_transformation_matrix_from_vectors(x, y, z):
    x_local = x.normalize()
    y_local = y.normalize()
    z_local = z.normalize()

    m = FreeCAD.Matrix()
    if z_local is not None:
        m.A11 = x_local.x
        m.A12 = y_local.x
        m.A13 = z_local.x
        m.A21 = x_local.y
        m.A22 = y_local.y
        m.A23 = z_local.y
        m.A31 = x_local.z
        m.A32 = y_local.z
        m.A33 = z_local.z

    return m 
开发者ID:execuc,项目名称:LCInterlocking,代码行数:20,代码来源:crosspart.py

示例5: get_matrix_transform

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import Matrix [as 别名]
def get_matrix_transform(face):
    x_local, y_local_not_normalized, z_local_not_normalized = get_local_axis(face)
    y_local = y_local_not_normalized.normalize()
    z_local = z_local_not_normalized.normalize()

    m = FreeCAD.Matrix()
    if z_local is not None:
        m.A11 = x_local.x
        m.A12 = y_local.x
        m.A13 = z_local.x
        m.A21 = x_local.y
        m.A22 = y_local.y
        m.A23 = z_local.y
        m.A31 = x_local.z
        m.A32 = y_local.z
        m.A33 = z_local.z

    return m 
开发者ID:execuc,项目名称:LCInterlocking,代码行数:20,代码来源:helper.py

示例6: __init__

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import Matrix [as 别名]
def __init__(self, info):
        self.info = info.ElementInfo
        idx = len(self.info.Subname)
        if idx:
            sub = info.SelSubname[:-idx]
        else:
            sub = info.SelSubname
        _,mat = info.SelObj.getSubObject(sub,1,FreeCAD.Matrix())
        pos = utils.getElementPos(self.info.Shape)
        if not pos:
            pos = self.info.Shape.BoundBox.Center
        pos = mat.multiply(pos)
        self.matrix = mat*self.info.Placement.inverse().toMatrix()
        base = self.matrix.multiply(self.info.Placement.Base)
        self.offset = pos - base

        self.matrix.invert()
        self.view = info.SelObj.ViewObject.Document.ActiveView
        self.callbackMove = self.view.addEventCallback(
                "SoLocation2Event",self.moveMouse)
        self.callbackClick = self.view.addEventCallback(
                "SoMouseButtonEvent",self.clickMouse)
        self.callbackKey = self.view.addEventCallback(
                "SoKeyboardEvent",self.keyboardEvent)
        FreeCAD.setActiveTransaction('Assembly quick move',True)
        self.active = True 
开发者ID:realthunder,项目名称:FreeCAD_assembly3,代码行数:28,代码来源:mover.py

示例7: execute

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import Matrix [as 别名]
def execute(self,obj):
        link = obj.LinkedObject
        if isinstance(link,tuple):
            subname = link[1]
            link = link[0]
        else:
            subname = ''
        linked,mat = link.getSubObject(subname,1,FreeCAD.Matrix())
        if linked and linked.Label != linked.Name:
            obj.Label = linked.Label

        info = None
        if getattr(obj,'Count',None):
            info = self.getInfo(True)

        version = self.childVersion(linked,mat)
        if not self.version.update(version):
            logger.debug('skip {}, {}, {}',
                objName(obj),self.version.childVersion,version)
            return
        logger.debug('not skip {}, {}',objName(obj),version)

        if not info:
            info = self.getInfo(True)
        relationGroup = self.getAssembly().getRelationGroup()
        if relationGroup and (not self.part or self.part!=info.Part):
            oldPart = self.part
            self.part = info.Part
            relationGroup.Proxy.update(
                    self.parent.Object,oldPart,info.Part,info.PartName)
        self.version.commit()
        return False 
开发者ID:realthunder,项目名称:FreeCAD_assembly3,代码行数:34,代码来源:assembly.py

示例8: matrixAt

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import Matrix [as 别名]
def matrixAt(self, p, i):
        t = self.rails[i].valueAt(p)
        u,v,w = self.frameAt(p,i)
        m = FreeCAD.Matrix( u.x, v.x, w.x, t.x,
                            u.y, v.y, w.y, t.y,
                            u.z, v.z, w.z, t.z,
                            0.0, 0.0, 0.0, 1.0)
        return(m) 
开发者ID:tomate44,项目名称:CurvesWB,代码行数:10,代码来源:libS2R.py

示例9: matrix1At

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import Matrix [as 别名]
def matrix1At(self, p):
        t = self.rail1.valueAt(p)
        u,v,w = self.frame1At(p)
        m=FreeCAD.Matrix( u.x,v.x,w.x,t.x,
                      u.y,v.y,w.y,t.y,
                      u.z,v.z,w.z,t.z,
                      0.0,0.0,0.0,1.0)
        return m 
开发者ID:tomate44,项目名称:CurvesWB,代码行数:10,代码来源:Birail.py

示例10: matrix2At

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import Matrix [as 别名]
def matrix2At(self, p):
        t = self.rail2.valueAt(p)
        u,v,w = self.frame2At(p)
        m=FreeCAD.Matrix( u.x,v.x,w.x,t.x,
                      u.y,v.y,w.y,t.y,
                      u.z,v.z,w.z,t.z,
                      0.0,0.0,0.0,1.0)
        return m 
开发者ID:tomate44,项目名称:CurvesWB,代码行数:10,代码来源:Birail.py

示例11: execute

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import Matrix [as 别名]
def execute(self, fp):
        inner_diameter = fp.module.Value * fp.teeth
        outer_diameter = inner_diameter + fp.height.Value * 2
        inner_circle = Part.Wire(Part.makeCircle(inner_diameter / 2.))
        outer_circle = Part.Wire(Part.makeCircle(outer_diameter / 2.))
        inner_circle.reverse()
        face = Part.Face([outer_circle, inner_circle])
        solid = face.extrude(App.Vector([0., 0., -fp.thickness.Value]))

        # cutting obj
        alpha_w = np.deg2rad(fp.pressure_angle.Value)
        m = fp.module.Value
        t = fp.teeth
        t_c = t
        t_i = fp.other_teeth
        rm = inner_diameter / 2
        y0 = m * 0.5
        y1 = m + y0
        y2 = m
        r0 = inner_diameter / 2 - fp.height.Value * 0.1
        r1 = outer_diameter / 2 + fp.height.Value * 0.3
        polies = []
        for r_i in np.linspace(r0, r1, fp.num_profiles):
            pts = self.profile(m, r_i, rm, t_c, t_i, alpha_w, y0, y1, y2)
            poly = Wire(makePolygon(list(map(fcvec, pts))))
            polies.append(poly)
        loft = makeLoft(polies, True)
        rot = App.Matrix()
        rot.rotateZ(2 * np.pi / t)
        if fp.construct:
            cut_shapes = [solid]
            for _ in range(t):
                loft = loft.transformGeometry(rot)
                cut_shapes.append(loft)
            fp.Shape = Part.Compound(cut_shapes)
        else:
            for i in range(t):
                loft = loft.transformGeometry(rot)
                solid = solid.cut(loft)
            fp.Shape = solid 
开发者ID:looooo,项目名称:freecad.gears,代码行数:42,代码来源:features.py

示例12: world_to_local_transform

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import Matrix [as 别名]
def world_to_local_transform(self):
        """
        :return: 3d affine transform matrix to convert world coordinates to local coordinates.
        :rtype: :class:`cadquery.Matrix`

        For matrix structure, see :meth:`from_transform`.
        """
        return self.fG 
开发者ID:cqparts,项目名称:cqparts,代码行数:10,代码来源:geometry.py

示例13: local_to_world_transform

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import Matrix [as 别名]
def local_to_world_transform(self):
        """
        :return: 3d affine transform matrix to convert local coordinates to world coordinates.
        :rtype: :class:`cadquery.Matrix`

        For matrix structure, see :meth:`from_transform`.
        """
        return self.rG 
开发者ID:cqparts,项目名称:cqparts,代码行数:10,代码来源:geometry.py

示例14: mat2list

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import Matrix [as 别名]
def mat2list(m, digits=7):
        """Converts FreeCAD.Base.Matrix to a list"""
        return [
            round(v, digits)
            for v in [
                m.A11, m.A12, m.A13, m.A14,
                m.A21, m.A22, m.A23, m.A24,
                m.A31, m.A32, m.A33, m.A34,
                m.A41, m.A42, m.A43, m.A44
            ]
        ] 
开发者ID:cqparts,项目名称:cqparts,代码行数:13,代码来源:test_coordsystem.py

示例15: assertMatrixAlmostEquals

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import Matrix [as 别名]
def assertMatrixAlmostEquals(self, first, second, places=6):
        """
        :param first: matrix
        :type first: :class:`FreeCAD.Base.Matrix`
        :param second: list of 16 numbers (of a 4x4 matrix)
        :type second: :class:`list`
        """
        for (a, b) in zip(self.mat2list(first), second):
            self.assertAlmostEqual(a, b, places=places) 
开发者ID:cqparts,项目名称:cqparts,代码行数:11,代码来源:test_coordsystem.py


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