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


Python Vector.dot方法代码示例

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


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

示例1: scale_verts_by_bone

# 需要导入模块: from mathutils import Vector [as 别名]
# 或者: from mathutils.Vector import dot [as 别名]
    def scale_verts_by_bone(self, pbone, armature, mesh_object, vert_co, weight=1.0):
        # verts = mesh_object.data.vertices
        bone = armature.data.bones[pbone.name]
        bone_head = self.init_bone_positions[bone.name]["head"]
        bone_tail = self.init_bone_positions[bone.name]["tail"]
        bone_axis_x = (bone_tail - bone_head).normalized().xz
        bone_axis_y = bone_axis_x.orthogonal().normalized()

        world_axis_x = Vector((bone_axis_x.dot(Vector((1, 0))), bone_axis_y.dot(Vector((1, 0)))))
        world_axis_y = Vector((bone_axis_x.dot(Vector((0, 1))), bone_axis_y.dot(Vector((0, 1)))))

        bone_system_origin = (mesh_object.matrix_world.inverted() * (armature.matrix_world * bone_head)).xz

        bone_scale = pbone.matrix.to_scale()
        bone_scale_2d = Vector(( self.lerp( 1.0, bone_scale.y, weight), self.lerp(1.0, bone_scale.x, weight) ))

        vert_delta_co = vert_co.xz
        vert_delta_co -= bone_system_origin
        vert_delta_co = Vector((bone_axis_x.dot(vert_delta_co), bone_axis_y.dot(vert_delta_co)))
        vert_delta_co = Vector((vert_delta_co.x * bone_scale_2d.x, vert_delta_co.y * bone_scale_2d.y))
        vert_delta_co = Vector((world_axis_x.dot(vert_delta_co), world_axis_y.dot(vert_delta_co)))
        vert_delta_co += bone_system_origin

        scaled_vert_co = Vector((vert_delta_co.x, 0, vert_delta_co.y))
        return scaled_vert_co
开发者ID:ndee85,项目名称:coa_tools,代码行数:27,代码来源:export_creature.py

示例2: vec_roll_to_mat3

# 需要导入模块: from mathutils import Vector [as 别名]
# 或者: from mathutils.Vector import dot [as 别名]
def vec_roll_to_mat3(axis, roll):
    """Computes 3x3 Matrix from rotation axis and its roll.

    :param axis: Rotation
    :type axis: Vector
    :param roll: Roll
    :type roll: float
    :return: 3x3 Matrix
    :rtype: Matrix
    """
    nor = axis.normalized()
    target = Vector((0, 1, 0))
    axis = target.cross(nor)

    if axis.dot(axis) > 1.0e-9:
        axis.normalize()
        theta = _math_utils.angle_normalized_v3v3(target, nor)
        b_matrix = Matrix.Rotation(theta, 4, axis)
    else:
        if target.dot(nor) > 0:
            up_or_down = 1.0
        else:
            up_or_down = -1.0

        b_matrix = Matrix()
        b_matrix[0] = (up_or_down, 0, 0, 0)
        b_matrix[1] = (0, up_or_down, 0, 0)
        b_matrix[2] = (0, 0, 1, 0)
        b_matrix[3] = (0, 0, 0, 1)

    roll_matrix = Matrix.Rotation(roll, 4, nor)
    return (roll_matrix * b_matrix).to_3x3()
开发者ID:P-casper1,项目名称:BlenderTools,代码行数:34,代码来源:convert.py

示例3: project

# 需要导入模块: from mathutils import Vector [as 别名]
# 或者: from mathutils.Vector import dot [as 别名]
def project(v, normal):
	p1, p2 = projectionAxis[tuple(normal)]
	p1, p2 = Vector(p1), Vector(p2)
	result = (p1.dot(v), p2.dot(v))
	print("res", result, "normal", tuple(normal))

	return result
开发者ID:metropolik,项目名称:bmexp,代码行数:9,代码来源:bmexp.py

示例4: _is_flat_face

# 需要导入模块: from mathutils import Vector [as 别名]
# 或者: from mathutils.Vector import dot [as 别名]
def _is_flat_face(normal):
    a = Vector(normal[0])
    for n in normal[1:]:
        dp = a.dot(Vector(n))
        if dp < 0.99999 or dp > 1.00001:
            return False
    return True
开发者ID:omni360,项目名称:bpycollada,代码行数:9,代码来源:import_collada.py

示例5: by_edge_dir

# 需要导入模块: from mathutils import Vector [as 别名]
# 或者: from mathutils.Vector import dot [as 别名]
    def by_edge_dir(self, vertices, edges, faces):
        percent = self.inputs['Percent'].sv_get(default=[1.0])[0][0]
        direction = self.inputs['Direction'].sv_get()[0][0]
        dirvector = Vector(direction)
        dirlength = dirvector.length
        if dirlength <= 0:
            raise ValueError("Direction vector must have nonzero length!")

        values = []
        for i, j in edges:
            u = vertices[i]
            v = vertices[j]
            edge = Vector(u) - Vector(v)
            if edge.length > 0:
                value = abs(edge.dot(dirvector)) / (edge.length * dirlength)
            else:
                value = 0
            values.append(value)
        threshold = self.map_percent(values, percent)
    
        out_edges_mask = [(value >= threshold) for value in values]
        out_edges = [edge for (edge, mask) in zip (edges, out_edges_mask) if mask]
        out_verts_mask = self.select_verts_by_faces(out_edges, vertices)
        out_faces_mask = self.select_faces_by_verts(out_verts_mask, faces)

        return out_verts_mask, out_edges_mask, out_faces_mask
开发者ID:johnyc90,项目名称:sverchok,代码行数:28,代码来源:mesh_select.py

示例6: region_2d_to_vector_3d

# 需要导入模块: from mathutils import Vector [as 别名]
# 或者: from mathutils.Vector import dot [as 别名]
def region_2d_to_vector_3d(region, rv3d, coord):
    """
    Return a direction vector from the viewport at the specific 2d region
    coordinate.

    :arg region: region of the 3D viewport, typically bpy.context.region.
    :type region: :class:`bpy.types.Region`
    :arg rv3d: 3D region data, typically bpy.context.space_data.region_3d.
    :type rv3d: :class:`bpy.types.RegionView3D`
    :arg coord: 2d coordinates relative to the region:
       (event.mouse_region_x, event.mouse_region_y) for example.
    :type coord: 2d vector
    :return: normalized 3d vector.
    :rtype: :class:`mathutils.Vector`
    """
    from mathutils import Vector

    viewinv = rv3d.view_matrix.inverted()
    if rv3d.is_perspective:
        persinv = rv3d.perspective_matrix.inverted()

        out = Vector(((2.0 * coord[0] / region.width) - 1.0,
                      (2.0 * coord[1] / region.height) - 1.0,
                      -0.5
                     ))

        w = out.dot(persinv[3].xyz) + persinv[3][3]

        return ((persinv * out) / w) - viewinv.translation
    else:
        return viewinv.col[2].xyz.normalized()
开发者ID:Gamebasis,项目名称:3DGamebasisServer,代码行数:33,代码来源:view3d_utils.py

示例7: polygon_normal_angle_D

# 需要导入模块: from mathutils import Vector [as 别名]
# 或者: from mathutils.Vector import dot [as 别名]
def polygon_normal_angle_D(verts, poly, D):
    ''' The angle between the polygon normal and the given direction '''
    N = polygon_normal(verts, poly)
    v1 = Vector(N)
    v2 = Vector(D)
    v1.normalize()
    v2.normalize()
    angle = acos(v1.dot(v2)) # the angle in radians

    return angle
开发者ID:nortikin,项目名称:sverchok,代码行数:12,代码来源:polygon_sort.py

示例8: polygon_normal_angle_P

# 需要导入模块: from mathutils import Vector [as 别名]
# 或者: from mathutils.Vector import dot [as 别名]
def polygon_normal_angle_P(verts, poly, P):
    ''' The angle between the polygon normal and the vector from polygon center to given point '''
    N = polygon_normal(verts, poly)
    C = polygon_center(verts, poly)
    V = [P[0] - C[0], P[1] - C[1], P[2] - C[2]]
    v1 = Vector(N)
    v2 = Vector(V)
    v1.normalize()
    v2.normalize()
    angle = acos(v1.dot(v2)) # the angle in radians

    return angle
开发者ID:nortikin,项目名称:sverchok,代码行数:14,代码来源:polygon_sort.py

示例9: vec_roll_to_mat3

# 需要导入模块: from mathutils import Vector [as 别名]
# 或者: from mathutils.Vector import dot [as 别名]
def vec_roll_to_mat3(vec, roll):
	target = Vector((0,1,0))
	nor = vec.normalized()
	axis = target.cross(nor)
	if axis.dot(axis) > 0.000001:
		axis.normalize()
		theta = target.angle(nor)
		bMatrix = Matrix.Rotation(theta, 3, axis)
	else:
		updown = 1 if target.dot(nor) > 0 else -1
		bMatrix = Matrix.Scale(updown, 3)
	rMatrix = Matrix.Rotation(roll, 3, nor)
	mat = rMatrix * bMatrix
	return mat
开发者ID:uthaman22,项目名称:asstools,代码行数:16,代码来源:iqe_import.py

示例10: area_pol

# 需要导入模块: from mathutils import Vector [as 别名]
# 或者: from mathutils.Vector import dot [as 别名]
def area_pol(poly):
    if len(poly) < 3:  # not a plane - no area
        return 0

    total = Vector((0, 0, 0))
    for i in range(len(poly)):
        vi1 = Vector(poly[i])
        if i is len(poly)-1:
            vi2 = Vector(poly[0])
        else:
            vi2 = Vector(poly[i+1])

        prod = vi1.cross(vi2)[:]
        total[0] += prod[0]
        total[1] += prod[1]
        total[2] += prod[2]

    result = total.dot(unit_normal(poly[0], poly[1], poly[2]))
    return abs(result/2)
开发者ID:gfcprogramer,项目名称:sverchok,代码行数:21,代码来源:area.py

示例11: polygon_area

# 需要导入模块: from mathutils import Vector [as 别名]
# 或者: from mathutils.Vector import dot [as 别名]
def polygon_area(verts, poly):
    ''' The area of the given polygon '''
    if len(poly) < 3:  # not a plane - no area
        return 0

    total = Vector([0, 0, 0])
    N = len(poly)
    for i in range(N):
        vi1 = Vector(verts[poly[i]])
        vi2 = Vector(verts[poly[(i + 1) % N]])
        prod = vi1.cross(vi2)
        total[0] += prod[0]
        total[1] += prod[1]
        total[2] += prod[2]

    normal = Vector(polygon_normal(verts, poly))
    area = abs(total.dot(normal)) / 2

    return area
开发者ID:nortikin,项目名称:sverchok,代码行数:21,代码来源:polygon_sort.py

示例12: matchIkLeg

# 需要导入模块: from mathutils import Vector [as 别名]
# 或者: from mathutils.Vector import dot [as 别名]
def matchIkLeg(legIk, toeFk, mBall, mToe, mHeel):
    rmat = toeFk.matrix.to_3x3()
    tHead = Vector(toeFk.matrix.col[3][:3])
    ty = rmat.col[1]
    tail = tHead + ty * toeFk.bone.length

    zBall = mBall.matrix.col[3][2]
    zToe = mToe.matrix.col[3][2]
    zHeel = mHeel.matrix.col[3][2]

    x = Vector(rmat.col[0])
    y = Vector(rmat.col[1])
    z = Vector(rmat.col[2])

    if zHeel > zBall and zHeel > zToe:
        # 1. foot.ik is flat
        if abs(y[2]) > abs(z[2]):
            y = -z
        y[2] = 0
    else:
        # 2. foot.ik starts at heel
        hHead = Vector(mHeel.matrix.col[3][:3])
        y = tail - hHead

    y.normalize()
    x -= x.dot(y)*y
    x.normalize()
    if abs(x[2]) < 0.7:
        x[2] = 0
        x.normalize()
    z = x.cross(y)
    head = tail - y * legIk.bone.length

    # Create matrix
    gmat = Matrix()
    gmat.col[0][:3] = x
    gmat.col[1][:3] = y
    gmat.col[2][:3] = z
    gmat.col[3][:3] = head
    pmat = getPoseMatrix(gmat, legIk)

    insertLocation(legIk, pmat)
    insertRotation(legIk, pmat)
开发者ID:jultrunb,项目名称:ass,代码行数:45,代码来源:fkik.py

示例13: region_2d_to_orig_and_view_vector

# 需要导入模块: from mathutils import Vector [as 别名]
# 或者: from mathutils.Vector import dot [as 别名]
def region_2d_to_orig_and_view_vector(region, rv3d, coord, clamp=None):
    viewinv = rv3d.view_matrix.inverted()
    persinv = rv3d.perspective_matrix.inverted()

    dx = (2.0 * coord[0] / region.width) - 1.0
    dy = (2.0 * coord[1] / region.height) - 1.0

    if rv3d.is_perspective:
        origin_start = viewinv.translation.copy()

        out = Vector((dx, dy, -0.5))

        w = out.dot(persinv[3].xyz) + persinv[3][3]

        view_vector = ((persinv * out) / w) - origin_start
    else:
        view_vector = -viewinv.col[2].xyz

        origin_start = ((persinv.col[0].xyz * dx) +
                        (persinv.col[1].xyz * dy) +
                        viewinv.translation)

        if clamp != 0.0:
            if rv3d.view_perspective != 'CAMERA':
                # this value is scaled to the far clip already
                origin_offset = persinv.col[2].xyz
                if clamp is not None:
                    if clamp < 0.0:
                        origin_offset.negate()
                        clamp = -clamp
                    if origin_offset.length > clamp:
                        origin_offset.length = clamp

                origin_start -= origin_offset

    view_vector.normalize()
    return origin_start, view_vector
开发者ID:8Observer8,项目名称:myblendercontrib,代码行数:39,代码来源:mesh_snap_utilities_line.py

示例14: region_2d_to_orig_and_view_vector

# 需要导入模块: from mathutils import Vector [as 别名]
# 或者: from mathutils.Vector import dot [as 别名]
def region_2d_to_orig_and_view_vector(region, rv3d, coord):
    viewinv = rv3d.view_matrix.inverted_safe()
    persinv = rv3d.perspective_matrix.inverted_safe()

    dx = (2.0 * coord[0] / region.width) - 1.0
    dy = (2.0 * coord[1] / region.height) - 1.0

    if rv3d.is_perspective:
        origin_start = viewinv.translation.copy()

        out = Vector((dx, dy, -0.5))

        w = out.dot(persinv[3].xyz) + persinv[3][3]

        view_vector = ((persinv @ out) / w) - origin_start
    else:
        view_vector = -viewinv.col[2].xyz

        origin_start = ((persinv.col[0].xyz * dx) +
                        (persinv.col[1].xyz * dy) +
                        viewinv.translation)

    view_vector.normalize()
    return view_vector, origin_start
开发者ID:sambler,项目名称:myblenderaddons,代码行数:26,代码来源:utils_projection.py

示例15: _arc_segment

# 需要导入模块: from mathutils import Vector [as 别名]
# 或者: from mathutils.Vector import dot [as 别名]
def _arc_segment(v_1, v_2):
	ELorigin = bpy.context.scene.objects['ELorigin']
	ELground = bpy.context.scene.objects['ELground']

	v = v_2 - v_1
	d = v.length

	ELorigin.location = Vector((0, 0, 0))
	ELground.location = Vector((0, 0, -d))

	v_L = ELground.location - ELorigin.location

	q = Quaternion()
	c = Vector.cross(v_L, v)
	q.x = c.x
	q.y = c.y
	q.z = c.z
	q.w = sqrt((v_L.length ** 2) * (v.length ** 2)) + \
		Vector.dot(v_L, v)
	q.normalize()
	euler = q.to_euler()

	bpy.ops.object.runfslg_operator()

	laALL = bpy.context.scene.objects['laALL']
	laALL.name = 'lARC'
	laALL.rotation_euler = euler
	laALL.location = v_1

	bpy.context.active_object.select = False
	laALL.select = True
	bpy.ops.object.transform_apply(location=True, rotation=True, scale=True)
	laALL.select = False
	bpy.context.active_object.select = True	

	return laALL
开发者ID:sadaszewski,项目名称:blender-addons,代码行数:38,代码来源:lightning_arcs.py


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