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


Python Matrix.to_euler方法代码示例

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


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

示例1: parseTree

# 需要导入模块: from mathutils import Matrix [as 别名]
# 或者: from mathutils.Matrix import to_euler [as 别名]
def parseTree(tree, parentName):
    # print("parsetree")
    armName = bpy.context.active_object.name
    armatures.createBone(armName, tree.name, parentName)
    bpy.ops.roboteditor.select_segment(segment_name=tree.name)
    # print(tree.name)
    boneProp = bpy.context.active_bone.RobotEditor

    m = Matrix()
    # print(tree.transformations)
    for i in tree.transformations:
        # We expect a matrix here!
        # Todo accept rotation and translations too!
        if type(i[0]) is list:
            m = m * Matrix(i)
        elif len(i) == 3:
            # TODO
            pass
        elif len(i) == 4:
            # TODO
            pass
        else:
            raise Exception("ParsingError")
            # print(m)

    bpy.context.active_bone.RobotEditor.Euler.x.value = m.translation[0] / 1000
    bpy.context.active_bone.RobotEditor.Euler.y.value = m.translation[1] / 1000
    bpy.context.active_bone.RobotEditor.Euler.z.value = m.translation[2] / 1000

    bpy.context.active_bone.RobotEditor.Euler.gamma.value = degrees(m.to_euler().z)
    bpy.context.active_bone.RobotEditor.Euler.beta.value = degrees(m.to_euler().y)
    bpy.context.active_bone.RobotEditor.Euler.alpha.value = degrees(m.to_euler().x)

    if tree.axis_type == 'revolute':
        bpy.context.active_bone.RobotEditor.jointMode = 'REVOLUTE'
        # boneProp.theta.value = float(tree.initalValue)
        bpy.context.active_bone.RobotEditor.theta.max = float(tree.max)
        bpy.context.active_bone.RobotEditor.theta.min = float(tree.min)
    else:
        bpy.context.active_bone.RobotEditor.jointMode = 'PRISMATIC'
        # boneProp.d.value = float(tree.initialValue)
        bpy.context.active_bone.RobotEditor.d.max = float(tree.max)
        bpy.context.active_bone.RobotEditor.d.min = float(tree.min)

    if tree.axis is not None:
        for i, axis in enumerate(tree.axis):
            if axis == -1.0:
                bpy.context.active_bone.RobotEditor.axis_revert = True
                tree.axis[i] = 1.0

        if tree.axis == [1.0, 0.0, 0.0]:
            bpy.context.active_bone.RobotEditor.axis = 'X'
        elif tree.axis == [0.0, 1.0, 0.0]:
            bpy.context.active_bone.RobotEditor.axis = 'Y'
        elif tree.axis == [0.0, 0.0, 1.0]:
            bpy.context.active_bone.RobotEditor.axis = 'Z'
    # print("parsetree done")

    for child in tree.children:
        parseTree(child, tree.name)
开发者ID:HBPNeurorobotics,项目名称:BlenderRobotDesigner,代码行数:62,代码来源:files.py

示例2: mirrorPlane

# 需要导入模块: from mathutils import Matrix [as 别名]
# 或者: from mathutils.Matrix import to_euler [as 别名]
def mirrorPlane(vertex, matrix):
    vert = []
    a = Matrix(matrix)
    eul = a.to_euler()
    normal = Vector((0.0, 0.0, 1.0))
    normal.rotate(eul)
    tras = Matrix.Translation(2*a.to_translation())
    for i in vertex:
        v = Vector(i)
        r = v.reflect(normal)
        vert.append((tras*r)[:])
    return vert
开发者ID:BitByte01,项目名称:myblendercontrib,代码行数:14,代码来源:mirror.py

示例3: rotate

# 需要导入模块: from mathutils import Matrix [as 别名]
# 或者: from mathutils.Matrix import to_euler [as 别名]
 def rotate(self, reference, R_1_1, R_1_2, R_1_3, R_2_1,R_2_2, R_2_3, R_3_1, R_3_2, R_3_3, frame, immediate=False):
     if None in [R_1_1, R_1_2, R_1_3, R_2_1,R_2_2, R_2_3, R_3_1, R_3_2, R_3_3] : return "Argument error."
     o = data.objects[reference]
     context.scene.objects.active=o
     if immediate:
       o.keyframe_insert('rotation_euler', frame=frame - 1)
     
     m = Matrix(([R_1_1,R_1_2, R_1_3],
                [R_2_1,R_2_2, R_2_3],
                [R_3_1,R_3_2, R_3_3]))
     e = m.to_euler()        
     ops.transform.rotate(value=(e[0],), axis=(1.0,0,0))
     ops.transform.rotate(value=(e[1],), axis=(0,1.0,0))
     ops.transform.rotate(value=(e[2],), axis=(0,0,1.0))
     o.keyframe_insert('rotation_euler', frame=frame)
     return reference
开发者ID:OpenModelica,项目名称:modelica3d,代码行数:18,代码来源:dbus-server.py

示例4: transformToLocal

# 需要导入模块: from mathutils import Matrix [as 别名]
# 或者: from mathutils.Matrix import to_euler [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

示例5: to_bl_obj

# 需要导入模块: from mathutils import Matrix [as 别名]
# 或者: from mathutils.Matrix import to_euler [as 别名]
    def to_bl_obj(self):
        "Convert this hardpoint to a Blender object."
        import bpy
        from mathutils import Matrix, Vector
        bl_obj = bpy.data.objects.new("hp-" + self.name, None)
        bl_obj.empty_draw_type = "ARROWS"

        matrix_rot = Matrix(self.rot_matrix).to_4x4()

        # Convert position/rotation from WC
        euler_rot = matrix_rot.to_euler("XYZ")
        euler_rot.y, euler_rot.z = -euler_rot.z, -euler_rot.y
        euler_rot.x *= -1

        matrix_rot = euler_rot.to_matrix().to_4x4()
        vector_loc = Vector(self.location)
        vector_loc.y, vector_loc.z = vector_loc.z, vector_loc.y
        matrix_loc = Matrix.Translation(vector_loc)

        bl_obj.matrix_basis = matrix_loc * matrix_rot
        return bl_obj
开发者ID:Talon1024,项目名称:WCPBlenderExporter,代码行数:23,代码来源:iff_mesh.py

示例6: sphere_to_euler

# 需要导入模块: from mathutils import Matrix [as 别名]
# 或者: from mathutils.Matrix import to_euler [as 别名]
def sphere_to_euler(vecx, vecy, vecz):
    """
    convert sphere orientation vectors to euler
    """
    M = Matrix((vecx, vecy, vecz))
    return M.to_euler()
开发者ID:Tob1112,项目名称:turbulent-weasel,代码行数:8,代码来源:panorama_tracker.py

示例7: zip

# 需要导入模块: from mathutils import Matrix [as 别名]
# 或者: from mathutils.Matrix import to_euler [as 别名]
X,Y,Z = np.meshgrid(xs,ys,zs)

X = X.ravel()
Y = Y.ravel()
Z = Z.ravel()

centers = zip(X,Y,Z)
    
ex = np.array([1,0,0])
ey = np.array([0,1,0])

rr = .75
for cc in centers:
    x,y,z = cc
    vv = [x,y,z]
    ehn = np.array([.5*y,-.5*x,1])
    
    bpy.ops.mesh.primitive_plane_add(location = vv[:]) 
    bb = bpy.context.scene.objects.active
    
    X = np.array([ehn,ex,ey])
    X = gs_3D(ehn)
    X = Matrix([X[k] for k in [1,2,0]])
    X.transpose()
    bb.scale = [rr,rr,rr]
    bb.rotation_euler = X.to_euler()[:]

     

开发者ID:macbuse,项目名称:Heisenberg,代码行数:28,代码来源:horizontal_distrib.py


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