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


Python Matrix.Rotation方法代码示例

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


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

示例1: __init__

# 需要导入模块: from mathutils import Matrix [as 别名]
# 或者: from mathutils.Matrix import Rotation [as 别名]
def __init__(self, blender_data=None):
        self.index = 0
        self.name = ''
        self.parent = None
        self.children = []
        self.animations = []
        self.matrix_basis = Matrix((
            (1.0, 0.0, 0.0, 0.0),
            (0.0, 0.0, 1.0, 0.0),
            (0.0, -1.0, 0.0, 0.0),
            (0.0, 0.0, 0.0, 1.0),
        )) * Matrix.Rotation(1.5707963267948966*2, 4, 'Z')

        self.matrix_basis = utils.magick_convert(self.matrix_basis)

        if blender_data:
            self.blender_data = blender_data
            self.name = blender_data.name 
开发者ID:alrusdi,项目名称:leadwerks-blender-exporter,代码行数:20,代码来源:armature.py

示例2: main_consts

# 需要导入模块: from mathutils import Matrix [as 别名]
# 或者: from mathutils.Matrix import Rotation [as 别名]
def main_consts():
    from math import radians

    global ROTMAT_2D_POS_90D
    global ROTMAT_2D_POS_45D
    global RotMatStepRotation

    ROTMAT_2D_POS_90D = Matrix.Rotation(radians(90.0), 2)
    ROTMAT_2D_POS_45D = Matrix.Rotation(radians(45.0), 2)

    RotMatStepRotation = []
    rot_angle = 22.5 #45.0/2
    while rot_angle > 0.1:
        RotMatStepRotation.append([
            Matrix.Rotation(radians(+rot_angle), 2),
            Matrix.Rotation(radians(-rot_angle), 2),
            ])

        rot_angle = rot_angle/2.0 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:21,代码来源:uvcalc_smart_project.py

示例3: _findOrCreateCamera

# 需要导入模块: from mathutils import Matrix [as 别名]
# 或者: from mathutils.Matrix import Rotation [as 别名]
def _findOrCreateCamera(context):
        scene = context.scene

        if scene.camera:
            return scene.camera

        cam = bpy.data.cameras.new(name="Camera")
        camob = bpy.data.objects.new(name="Camera", object_data=cam)
        scene.objects.link(camob)

        scene.camera = camob

        camob.matrix_local = (Matrix.Translation((7.481, -6.508, 5.344)) *
                              Matrix.Rotation(0.815, 4, 'Z') *
                              Matrix.Rotation(0.011, 4, 'Y') *
                              Matrix.Rotation(1.109, 4, 'X'))

        return camob 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:20,代码来源:clip.py

示例4: SVGTransformRotate

# 需要导入模块: from mathutils import Matrix [as 别名]
# 或者: from mathutils.Matrix import Rotation [as 别名]
def SVGTransformRotate(params):
    """
    skewX SVG transform command
    """

    ang = float(params[0]) * pi / 180.0
    cx = cy = 0.0

    if len(params) >= 3:
        cx = float(params[1])
        cy = float(params[2])

    tm = Matrix.Translation(Vector((cx, cy, 0.0)))
    rm = Matrix.Rotation(ang, 4, Vector((0.0, 0.0, 1.0)))

    return tm * rm * tm.inverted() 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:18,代码来源:import_svg.py

示例5: execute

# 需要导入模块: from mathutils import Matrix [as 别名]
# 或者: from mathutils.Matrix import Rotation [as 别名]
def execute(self, context):
        obs = context.selected_objects

        bpy.ops.curve.primitive_bezier_circle_add(radius=self.diameter / 2, rotation=(pi / 2, 0.0, 0.0))

        curve = context.object
        curve.name = "Size"
        curve.data.name = "Size"
        curve.data.resolution_u = 512
        curve.data.use_radius = False

        if self.up:
            mat = Matrix.Rotation(pi, 4, "Z")
            curve.data.transform(mat)

        if obs:
            for ob in obs:
                try:
                    md = ob.modifiers.new("Curve", "CURVE")
                    md.object = curve
                except AttributeError:
                    continue

        return {"FINISHED"} 
开发者ID:mrachinskiy,项目名称:jewelcraft,代码行数:26,代码来源:curve_ops.py

示例6: update_section

# 需要导入模块: from mathutils import Matrix [as 别名]
# 或者: from mathutils.Matrix import Rotation [as 别名]
def update_section(self, context):
        o = self.find_in_selection(context, self.auto_update)

        if o is None:
            return
        src_name = o.name
        loc = o.matrix_world.translation
        clip_x = 0.5 * self.size
        sel = []
        tM = self.get_objects(context, o, sel)

        # rotate section plane normal 90 deg on x axis
        pM = tM * Matrix.Rotation(pi / 2, 4, Vector((1, 0, 0)))
        s = self.generate_section(context, sel, pM, clip_x, 0)

        # get points in plane matrix coordsys so they are in 2d
        itM = pM.inverted()
        c = self.as_curves(context, s, itM, loc, src_name, self.section_name)
        if c is None:
            self.delete_object(context, s)
        else:
            self.section_name = c.name

        self.restore_context(context)
        return c 
开发者ID:s-leger,项目名称:archipack,代码行数:27,代码来源:archipack_section.py

示例7: transformToWorld

# 需要导入模块: from mathutils import Matrix [as 别名]
# 或者: from mathutils.Matrix import Rotation [as 别名]
def transformToWorld(vec:Vector, mat:Matrix, junk_bme:bmesh=None):
    """ transfrom vector to world space from 'mat' matrix local space """
    # decompose matrix
    loc = mat.to_translation()
    rot = mat.to_euler()
    scale = mat.to_scale()[0]
    # apply rotation
    if rot != Euler((0, 0, 0), "XYZ"):
        junk_bme = bmesh.new() if junk_bme is None else junk_bme
        v1 = junk_bme.verts.new(vec)
        bmesh.ops.rotate(junk_bme, verts=[v1], cent=-loc, matrix=Matrix.Rotation(rot.x, 3, 'X'))
        bmesh.ops.rotate(junk_bme, verts=[v1], cent=-loc, matrix=Matrix.Rotation(rot.y, 3, 'Y'))
        bmesh.ops.rotate(junk_bme, verts=[v1], cent=-loc, matrix=Matrix.Rotation(rot.z, 3, 'Z'))
        vec = v1.co
    # apply scale
    vec = vec * scale
    # apply translation
    vec += loc
    return vec 
开发者ID:patmo141,项目名称:object_alignment,代码行数:21,代码来源:transform.py

示例8: transformToLocal

# 需要导入模块: from mathutils import Matrix [as 别名]
# 或者: from mathutils.Matrix import Rotation [as 别名]
def transformToLocal(vec:Vector, mat:Matrix, junk_bme:bmesh=None):
    """ transfrom vector to local space of 'mat' matrix """
    # decompose matrix
    loc = mat.to_translation()
    rot = mat.to_euler()
    scale = mat.to_scale()[0]
    # apply scale
    vec = vec / scale
    # apply rotation
    if rot != Euler((0, 0, 0), "XYZ"):
        junk_bme = bmesh.new() if junk_bme is None else junk_bme
        v1 = junk_bme.verts.new(vec)
        bmesh.ops.rotate(junk_bme, verts=[v1], cent=loc, matrix=Matrix.Rotation(-rot.z, 3, 'Z'))
        bmesh.ops.rotate(junk_bme, verts=[v1], cent=loc, matrix=Matrix.Rotation(-rot.y, 3, 'Y'))
        bmesh.ops.rotate(junk_bme, verts=[v1], cent=loc, matrix=Matrix.Rotation(-rot.x, 3, 'X'))
        vec = v1.co
    return vec 
开发者ID:patmo141,项目名称:object_alignment,代码行数:19,代码来源:transform.py

示例9: bezierArcAt

# 需要导入模块: from mathutils import Matrix [as 别名]
# 或者: from mathutils.Matrix import Rotation [as 别名]
def bezierArcAt(tangent, normal, center, radius, angle, tollerance=0.99999):
    transform = Matrix.Identity(4)
    transform.col[0].xyz = tangent.cross(normal)*radius
    transform.col[1].xyz = tangent*radius
    transform.col[2].xyz = normal*radius
    transform.col[3].xyz = center
    segments = []
    segment_count = math.ceil(abs(angle)/(math.pi*0.5)*tollerance)
    angle /= segment_count
    x0 = math.cos(angle*0.5)
    y0 = math.sin(angle*0.5)
    x1 = (4.0-x0)/3.0
    y1 = (1.0-x0)*(3.0-x0)/(3.0*y0)
    points = [
        Vector((x0, -y0, 0)),
        Vector((x1, -y1, 0)),
        Vector((x1, y1, 0)),
        Vector((x0, y0, 0))
    ]
    for i in range(0, segment_count):
        rotation = Matrix.Rotation((i+0.5)*angle, 4, 'Z')
        segments.append(list(map(lambda v: transform@(rotation@v), points)))
    return segments 
开发者ID:Lichtso,项目名称:curve_cad,代码行数:25,代码来源:internal.py

示例10: mat3_to_vec_roll

# 需要导入模块: from mathutils import Matrix [as 别名]
# 或者: from mathutils.Matrix import Rotation [as 别名]
def mat3_to_vec_roll(mat):
    """Computes rotation axis and its roll from a Matrix.

    :param mat: Matrix
    :type mat: Matrix
    :return: Rotation axis and roll
    :rtype: Vector and float
    """
    mat_3x3 = mat.to_3x3()
    # print('  mat_3x3:\n%s' % str(mat_3x3))
    axis = Vector(mat_3x3.col[1]).normalized()
    # print('  axis:\n%s' % str(axis))
    # print('  mat_3x3[2]:\n%s' % str(mat_3x3.col[2]))

    zero_angle_matrix = vec_roll_to_mat3(axis, 0)
    delta_matrix = zero_angle_matrix.inverted() @ mat_3x3
    angle = math.atan2(delta_matrix.col[2][0], delta_matrix.col[2][2])
    return axis, angle 
开发者ID:SCSSoftware,项目名称:BlenderTools,代码行数:20,代码来源:convert.py

示例11: _compute_camera_to_world_trafo

# 需要导入模块: from mathutils import Matrix [as 别名]
# 或者: from mathutils.Matrix import Rotation [as 别名]
def _compute_camera_to_world_trafo(self, cam_H_m2w_ref, cam_H_m2c_ref):
        """ Returns camera to world transformation in blender coords.

        :param cam_H_m2c_ref: (4x4) Homog trafo from object to camera coords. Type: ndarray.
        :param cam_H_m2w_ref: (4x4) Homog trafo from object to world coords. Type: ndarray.
        :return: cam_H_c2w: (4x4) Homog trafo from camera to world coords. Type: mathutils.Matrix.
        """

        cam_H_c2w = np.dot(cam_H_m2w_ref, np.linalg.inv(cam_H_m2c_ref))

        print('-----------------------------')
        print("Cam: {}".format(cam_H_c2w))
        print('-----------------------------')

        # transform from OpenCV to blender coords
        cam_H_c2w = cam_H_c2w @ Matrix.Rotation(math.radians(180), 4, "X")

        return cam_H_c2w 
开发者ID:DLR-RM,项目名称:BlenderProc,代码行数:20,代码来源:BopLoader.py

示例12: geometry

# 需要导入模块: from mathutils import Matrix [as 别名]
# 或者: from mathutils.Matrix import Rotation [as 别名]
def geometry(self, frame=0):
        t = frame / self.frames
        Rot = Matrix.Rotation(0.5*pi, 4, 'Y')
        bm = bmesh.new()

        for i in range(self.n):
            t0 = i / self.n
            r0, theta = t0*self.r0, i*goldenAngle - frame*goldenAngle + t*self.offset

            x = r0*cos(theta)
            y = r0*sin(theta)
            z = self.h0/2 - (self.h0 / (self.r0*self.r0))*r0*r0
            p0 = Vector((x, y, z))

            T0, N0, B0 = getTNBfromVector(p0)
            M0 = Matrix([T0, B0, N0]).to_4x4().transposed()

            for j in range(self.m):
                t1 = j / self.m
                t2 = 0.4 + 0.6*t0
                r1, theta = t2*t1*self.r1, j*goldenAngle #- frame*goldenAngle + t*self.offset

                x = r1*cos(theta)
                y = r1*sin(theta)
                z = self.h1 - (self.h1 / (self.r1*self.r1))*r1*r1
                p1 = Vector((x, y, z))
                T1, N1, B1 = getTNBfromVector(p1)
                M1 = Matrix([T1, B1, N1]).to_4x4().transposed()

                p = p0 + M0*p1
                r2 = t2*t1*self.r2

                T = Matrix.Translation(p)
                bmesh.ops.create_cone(bm,
                                cap_ends=True, segments=6,
                                diameter1=r2, diameter2=r2,
                                depth=0.1*r2, matrix=T*M0*M1*Rot)
        return bm 
开发者ID:njanakiev,项目名称:blender-scripting,代码行数:40,代码来源:phyllotaxis_flower.py

示例13: rotate_uvs

# 需要导入模块: from mathutils import Matrix [as 别名]
# 或者: from mathutils.Matrix import Rotation [as 别名]
def rotate_uvs(uv_points, angle):

    if angle != 0.0:
        mat = Matrix.Rotation(angle, 2)
        for uv in uv_points:
            uv[:] = mat * uv 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:8,代码来源:uvcalc_smart_project.py

示例14: translateRotation

# 需要导入模块: from mathutils import Matrix [as 别名]
# 或者: from mathutils.Matrix import Rotation [as 别名]
def translateRotation(rot):
    """ axis, angle """
    return Matrix.Rotation(rot[3], 4, Vector(rot[:3])) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:5,代码来源:import_x3d.py

示例15: translateTexTransform

# 需要导入模块: from mathutils import Matrix [as 别名]
# 或者: from mathutils.Matrix import Rotation [as 别名]
def translateTexTransform(node, ancestry):
    cent = node.getFieldAsFloatTuple('center', None, ancestry)  # (0.0, 0.0)
    rot = node.getFieldAsFloat('rotation', None, ancestry)  # 0.0
    sca = node.getFieldAsFloatTuple('scale', None, ancestry)  # (1.0, 1.0)
    tx = node.getFieldAsFloatTuple('translation', None, ancestry)  # (0.0, 0.0)

    if cent:
        # cent is at a corner by default
        cent_mat = Matrix.Translation(Vector(cent).to_3d())
        cent_imat = cent_mat.inverted()
    else:
        cent_mat = cent_imat = None

    if rot:
        rot_mat = Matrix.Rotation(rot, 4, 'Z')  # translateRotation(rot)
    else:
        rot_mat = None

    if sca:
        sca_mat = translateScale((sca[0], sca[1], 0.0))
    else:
        sca_mat = None

    if tx:
        tx_mat = Matrix.Translation(Vector(tx).to_3d())
    else:
        tx_mat = None

    new_mat = Matrix()

    # as specified in VRML97 docs
    mats = [cent_imat, sca_mat, rot_mat, cent_mat, tx_mat]

    for mtx in mats:
        if mtx:
            new_mat = new_mat * mtx

    return new_mat 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:40,代码来源:import_x3d.py


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