本文整理汇总了Python中mathutils.Euler方法的典型用法代码示例。如果您正苦于以下问题:Python mathutils.Euler方法的具体用法?Python mathutils.Euler怎么用?Python mathutils.Euler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mathutils
的用法示例。
在下文中一共展示了mathutils.Euler方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ai_properties
# 需要导入模块: import mathutils [as 别名]
# 或者: from mathutils import Euler [as 别名]
def ai_properties(self):
scale = self.geometry_matrix_scale
matrix = Matrix([
[scale.x, 0, 0],
[0, scale.y, 0],
[0, 0, scale.z]
])
matrix.rotate(Euler(self.geometry_matrix_rotation))
matrix = matrix.to_4x4()
matrix.translation = (self.geometry_matrix_translation)
return {
"format": ('STRING', self.format),
"resolution": ('STRING', self.resolution),
"portal_mode": ('STRING', self.portal_mode),
"matrix": ('MATRIX', matrix),
"camera": ('BOOL', self.camera),
"diffuse": ('BOOL', self.diffuse),
"specular": ('BOOL', self.specular),
"sss": ('BOOL', self.sss),
"volume": ('BOOL', self.volume),
"transmission": ('BOOL', self.transmission)
}
示例2: reconstruct_rectangle
# 需要导入模块: import mathutils [as 别名]
# 或者: from mathutils import Euler [as 别名]
def reconstruct_rectangle(pa, pb, pc, pd, scale, focal):
# Calculate the coordinates of the rectangle in 3d
coords = get_lambda_d(pa, pb, pc, pd, scale, focal)
# Calculate the transformation of the rectangle
trafo = get_transformation(coords[0], coords[1], coords[2], coords[3])
# Reconstruct the rotation angles of the transformation
angles = get_rot_angles(trafo[0], trafo[1], trafo[2])
xyz_matrix = mathutils.Euler((angles[0], angles[1], angles[2]), "XYZ")
# Reconstruct the camera position and the corners of the rectangle in 3d such that it lies on the xy-plane
tr = trafo[-1]
cam_pos = apply_transformation([mathutils.Vector((0.0, 0.0, 0.0))], tr, xyz_matrix)[0]
corners = apply_transformation(coords, tr, xyz_matrix)
# Printout for debugging
print("Focal length:", focal)
print("Camera rotation:", degrees(angles[0]), degrees(angles[1]), degrees(angles[2]))
print("Camera position:", cam_pos)
length = (coords[0] - coords[1]).length
width = (coords[0] - coords[3]).length
size = max(length, width)
print("Rectangle length:", length)
print("Rectangle width:", width)
print("Rectangle corners:", corners)
return (cam_pos, xyz_matrix, corners, size)
示例3: fix_env_rotations
# 需要导入模块: import mathutils [as 别名]
# 或者: from mathutils import Euler [as 别名]
def fix_env_rotations():
try:
for world in bpy.data.worlds:
nodes = world.node_tree.nodes
links = world.node_tree.links
mapping = find_existing_mapping(nodes)
env = find_env_texture(nodes)
if mapping == False and env != False:
texture_coordinates = nodes.new("ShaderNodeTexCoord")
texture_coordinates.location = (-800, 145)
mapper = nodes.new("ShaderNodeMapping")
mapper.location = (-625, 145)
mapper.rotation = Euler((0.0, 0.0, 1.5707963705062866), 'XYZ')
links.new(mapper.inputs[0],
texture_coordinates.outputs["Object"])
links.new(env.inputs[0], mapper.outputs[0])
except Exception as e:
print(e)
示例4: text
# 需要导入模块: import mathutils [as 别名]
# 或者: from mathutils import Euler [as 别名]
def text(self, en, scene, name):
"""
en: dxf entity
name: ignored; exists to make separate and merged objects methods universally callable from _call_types()
Returns a new single line text object.
"""
if self.import_text:
name = en.text[:8]
d = bpy.data.curves.new(name, "FONT")
d.body = en.plain_text()
d.size = en.height
o = bpy.data.objects.new(name, d)
o.rotation_euler = Euler((0, 0, radians(en.rotation)), 'XYZ')
basepoint = self.proj(en.basepoint) if hasattr(en, "basepoint") else self.proj((0, 0, 0))
o.location = self.proj((en.insert)) + basepoint
if hasattr(en, "thickness"):
et = en.thickness / 2
d.extrude = abs(et)
if et > 0:
o.location.z += et
elif et < 0:
o.location.z -= et
return o
示例5: draw_arc12
# 需要导入模块: import mathutils [as 别名]
# 或者: from mathutils import Euler [as 别名]
def draw_arc12(x, y, radius, start_angle, end_angle, subdivide): # いずれ削除
# 十二時から時計回りに描画
v = Vector([0, 1, 0])
e = Euler((0, 0, -start_angle))
m = e.to_matrix()
v = v * m
if end_angle >= start_angle:
a = (end_angle - start_angle) / (subdivide + 1)
else:
a = (end_angle + math.pi * 2 - start_angle) / (subdivide + 1)
e = Euler((0, 0, -a))
m = e.to_matrix()
bgl.glBegin(bgl.GL_LINE_STRIP)
for i in range(subdivide + 2):
v1 = v * radius
bgl.glVertex2f(x + v1[0], y + v1[1])
v = v * m
bgl.glEnd()
示例6: list_to_mathutils
# 需要导入模块: import mathutils [as 别名]
# 或者: from mathutils import Euler [as 别名]
def list_to_mathutils(values: typing.List[float], data_path: str) -> typing.Union[Vector, Quaternion, Euler]:
"""Transform a list to blender py object."""
target = get_target_property_name(data_path)
if target == 'delta_location':
return Vector(values) # TODO Should be Vector(values) - Vector(something)?
elif target == 'delta_rotation_euler':
return Euler(values).to_quaternion() # TODO Should be multiply(Euler(values).to_quaternion(), something)?
elif target == 'location':
return Vector(values)
elif target == 'rotation_axis_angle':
angle = values[0]
axis = values[1:]
return Quaternion(axis, math.radians(angle))
elif target == 'rotation_euler':
return Euler(values).to_quaternion()
elif target == 'rotation_quaternion':
return Quaternion(values)
elif target == 'scale':
return Vector(values)
elif target == 'value':
return Vector(values)
return values
示例7: build
# 需要导入模块: import mathutils [as 别名]
# 或者: from mathutils import Euler [as 别名]
def build(self, buildRequest):
t = time.time()
rotDiff = random.uniform(self.settings["minRandRot"],
self.settings["maxRandRot"])
eul = mathutils.Euler(buildRequest.rot, 'XYZ')
eul.rotate_axis('Z', math.radians(rotDiff))
scaleDiff = random.uniform(self.settings["minRandSz"],
self.settings["maxRandSz"])
newScale = buildRequest.scale * scaleDiff
buildRequest.rot = Vector(eul)
buildRequest.scale = newScale
cm_timings.placement["TemplateRANDOM"] += time.time() - t
cm_timings.placementNum["TemplateRANDOM"] += 1
self.inputs["Template"].build(buildRequest)
示例8: transformToWorld
# 需要导入模块: import mathutils [as 别名]
# 或者: from mathutils import Euler [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
示例9: transformToLocal
# 需要导入模块: import mathutils [as 别名]
# 或者: from mathutils import 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
示例10: rotate_brain
# 需要导入模块: import mathutils [as 别名]
# 或者: from mathutils import Euler [as 别名]
def rotate_brain(dx=None, dy=None, dz=None, keep_rotating=False, save_image=False, render_image=False):
dx = bpy.context.scene.rotate_dx if dx is None else dx
dy = bpy.context.scene.rotate_dy if dy is None else dy
dz = bpy.context.scene.rotate_dz if dz is None else dz
ShowHideObjectsPanel.rotate_dxyz += np.array([dx, dy, dz])
bpy.context.scene.rotate_dx, bpy.context.scene.rotate_dy, bpy.context.scene.rotate_dz = dx, dy, dz
rv3d = mu.get_view3d_region()
rv3d.view_rotation.rotate(mathutils.Euler((math.radians(d) for d in (dx, dy, dz))))
if bpy.context.scene.rotate_and_save or save_image:
_addon().save_image('rotation', view_selected=bpy.context.scene.save_selected_view)
# if bpy.context.scene.rotate_and_render or render_image:
# _addon().render_image('rotation')
if bpy.context.scene.rotate_360 and any([ShowHideObjectsPanel.rotate_dxyz[k] >= 360 for k in range(3)]):
stop_rotating()
elif keep_rotating:
start_rotating()
示例11: animate_convert_rotation_euler
# 需要导入模块: import mathutils [as 别名]
# 或者: from mathutils import Euler [as 别名]
def animate_convert_rotation_euler(euler, rotation_mode):
"""
Converts an euler angle to a quaternion rotation.
"""
rotation = mathutils.Euler((euler[0], euler[1], euler[2]), rotation_mode).to_quaternion()
return [rotation.x, rotation.y, rotation.z, rotation.w]
示例12: clear_pose
# 需要导入模块: import mathutils [as 别名]
# 或者: from mathutils import Euler [as 别名]
def clear_pose(obj):
if obj.type == "ARMATURE":
for bone in obj.pose.bones:
bone.scale = Vector((1,1,1))
bone.location = Vector((0,0,0))
bone.rotation_euler = Euler((0,0,0),"XYZ")
bone.rotation_quaternion = Euler((0,0,0),"XYZ").to_quaternion()
elif obj.type == "MESH":
obj.coa_sprite_frame = 0
obj.coa_alpha = 1.0
obj.coa_modulate_color = (1.0,1.0,1.0)
#obj["coa_slot_index"] = max(0,len(obj.coa_slot)-1)
#obj["coa_slot_index"] = obj.coa_slot_reset_index
obj.coa_slot_index = 0
示例13: get_rot_angles
# 需要导入模块: import mathutils [as 别名]
# 或者: from mathutils import Euler [as 别名]
def get_rot_angles(ex, ey, ez):
"""Get the x- and y-rotation from the ez unit vector"""
rx = atan2(ez[1], ez[2])
rx_matrix = mathutils.Euler((rx, 0.0, 0.0), "XYZ")
# Rotate the ez vector by the previously found angle
ez.rotate(rx_matrix)
# Negative value because of right handed rotation
ry = - atan2(ez[0], ez[2])
# Rotate the ex vector by the previously found angles
rxy_matrix = mathutils.Euler((rx, ry, 0.0), "XYZ")
ex.rotate(rxy_matrix)
# Negative value because of right handed rotation
rz = - atan2(ex[1], ex[0])
return [rx, ry, rz]
示例14: set_bevel_spline
# 需要导入模块: import mathutils [as 别名]
# 或者: from mathutils import Euler [as 别名]
def set_bevel_spline(self, spline):
import math, mathutils
r = self.radius
vec = mathutils.Vector((0, r, 0))
min_rad = -math.radians(360 / len(spline.points))
for index, point in enumerate(spline.points):
eul = mathutils.Euler((0, 0, min_rad * index), 'XYZ')
now_vec = vec.copy()
now_vec.rotate(eul)
now_vec = self.get_random_point(now_vec)
point.co = list(now_vec[:]) + [1]
示例15: correct_scale_rotation
# 需要导入模块: import mathutils [as 别名]
# 或者: from mathutils import Euler [as 别名]
def correct_scale_rotation(obj, rotation):
reset_scale_rotation(obj)
obj.scale = Vector((100.0, 100.0, 100.0))
print(obj.scale)
str_angle = -90 * pi/180
if rotation:
obj.rotation_euler = Euler((str_angle, 0, 0), "XYZ")
reset_scale_rotation(obj)
obj.scale = Vector((0.01, 0.01, 0.01))
if rotation:
obj.rotation_euler = Euler((-str_angle, 0, 0), "XYZ")