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


Python Vector.angle_signed方法代码示例

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


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

示例1: calc_rotation

# 需要导入模块: from mathutils import Vector [as 别名]
# 或者: from mathutils.Vector import angle_signed [as 别名]
 def calc_rotation(self, curve, src, dst, plane=None):
     # Some hacks.
     # Problem: if src and/or dst are exactly parallel to
     # one of coordinate axes, then Vector.rotation_difference
     # sometimes returns a matrix that rotates our vector in
     # completely different plane.
     # For example, if whole figure lays in XY plane, and
     # we are trying to rotate src = (0, 1, 0) into dst = (1, 0, 0),
     # then rotation_difference might return us a matrix, which
     # rotates (-1, 0, 0) into (0, 0, -1), which is out of XY plane
     # ("because why no? it still rotates src into dst").
     # Solution (hack): if whole figure lays in XY plane, then do
     # not use general rotation_difference method, calculate
     # rotation along Z axis only.
     if plane == 'XY':
         # Another unobvious hack: Vector.angle_signed method
         # works with 2D vectors only (this is not stated in
         # it's documentation!). Fortunately, in this particular
         # case our vectors are actually 2D.
         dst = Vector((dst[0], dst[1]))
         src = Vector((src[0], src[1]))
         angle = dst.angle_signed(src)
         return Matrix.Rotation(angle, 4, 'Z')
     elif plane == 'YZ':
         dst = Vector((dst[1], dst[2]))
         src = Vector((src[1], src[2]))
         angle = dst.angle_signed(src)
         return Matrix.Rotation(angle, 4, 'X')
     elif plane == 'XZ':
         dst = Vector((dst[2], dst[0]))
         src = Vector((src[2], src[0]))
         angle = dst.angle_signed(src)
         return Matrix.Rotation(angle, 4, 'Y')
     else:
         return autorotate_diff(dst, src)
开发者ID:nortikin,项目名称:sverchok,代码行数:37,代码来源:fractal_curve.py

示例2: rounded_primitive

# 需要导入模块: from mathutils import Vector [as 别名]
# 或者: from mathutils.Vector import angle_signed [as 别名]
 def rounded_primitive(cls, verts, radius, resolution=2.0):
     if not verts: return
     if len(verts) == 1:
         yield from cls.arc(verts[0], radius, resolution, skip_end=1)
     elif len(verts) == 2:
         v0, v1 = verts
         dv = v1 - v0
         angle = Vector((0,1)).angle_signed(Vector((-dv.y, dv.x)), 0.0)
         yield from cls.arc(v0, radius, resolution, angle-math.pi, angle)
         yield from cls.arc(v1, radius, resolution, angle, angle+math.pi)
     elif radius == 0:
         yield from verts # exactly the same
     else:
         vref = Vector((0,1))
         count = len(verts)
         for i0 in range(count):
             v0 = verts[i0]
             v1 = verts[(i0 + 1) % count]
             v2 = verts[(i0 + 2) % count]
             dv10 = v1 - v0
             dv21 = v2 - v1
             angle10 = vref.angle_signed(Vector((-dv10.y, dv10.x)), 0.0)
             angle21 = vref.angle_signed(Vector((-dv21.y, dv21.x)), 0.0)
             angle21 = angle10 + clamp_angle(angle21 - angle10)
             yield from cls.arc(v1, radius, resolution, angle10, angle21)
开发者ID:TakamitsuNobe,项目名称:myblendercontrib,代码行数:27,代码来源:utils_gl.py

示例3: execute

# 需要导入模块: from mathutils import Vector [as 别名]
# 或者: from mathutils.Vector import angle_signed [as 别名]
    def execute(self,bgeCar):

        #vector between car and guide
        car_position = bgeCar.getPosition()
        guide_position = bgeCar.bgeGuide.getPosition()
        vec_to_guide = guide_position - car_position

        #car norm vector
        car_dir_vec = bgeCar.getVelocity()

        #in 2D
        vec_to_guide = Vector([vec_to_guide[0],vec_to_guide[1]])
        car_dir_vec = Vector([car_dir_vec[0],car_dir_vec[1]])
                
        #angle between the two
        angle = vec_to_guide.angle_signed(car_dir_vec,None)
        if angle==None:
            angleFormated = 0.0
        else:
            angleFormated = angle * 180/math.pi
        
        angle_treshold = 2.0
        
        if angleFormated > angle_treshold:
            bge.logic.sendMessage(bgeCar.carname + '_Left')
        elif angleFormated < -angle_treshold:
            bge.logic.sendMessage(bgeCar.carname + '_Right')
开发者ID:kleinmatgit,项目名称:AICarRacingTest,代码行数:29,代码来源:steering_controller.py

示例4: ang_2d_sort

# 需要导入模块: from mathutils import Vector [as 别名]
# 或者: from mathutils.Vector import angle_signed [as 别名]
 def ang_2d_sort(x):
     pt1=bm.verts[x].co
     vec=vm*wm*pt1-vm*wm*pt0
     vec=Vector(vec[0:2])
     ang=vec.angle_signed(Vector((1,0)))
     
     if ang<0:
         return ang+3.1415926*2
     else:
         return ang
开发者ID:luxuy,项目名称:BlenderAddons,代码行数:12,代码来源:mesh_to_wall.py

示例5: tractorAimError

# 需要导入模块: from mathutils import Vector [as 别名]
# 或者: from mathutils.Vector import angle_signed [as 别名]
 def tractorAimError(self):
     '''
     Return the angle between the vector the animal is
     facing, and the vector from the animal to the tractor.
     '''
     tractor = GameLogic.getCurrentScene().objects['tractor']
     p1 = self.worldPosition.copy()
     p1 = Vector((p1.x,p1.y))
     p2 = tractor.worldPosition.copy()
     p2 = Vector((p2.x,p2.y))
     v1 = self.orientation[:][1].copy()
     v1 = Vector((v1.x,v1.y*-1))
     v2 = p2 - p1
     return abs(v1.angle_signed(v2))
开发者ID:WartburgComputerClub,项目名称:tractor-drive,代码行数:16,代码来源:types.py

示例6: bulge_to_arc

# 需要导入模块: from mathutils import Vector [as 别名]
# 或者: from mathutils.Vector import angle_signed [as 别名]
def bulge_to_arc(point, next, bulge):
    """
    point: start point of segment in lwpolyline
    next: end point of segment in lwpolyline
    bulge: number between 0 and 1
    Converts a bulge of lwpolyline to an arc with a bulge describing the amount of how much a straight segment should
    be bended to an arc. With the bulge one can find the center point of the arc that replaces the segment.
    """

    rot = Matrix(((0, -1, 0), (1, 0, 0), (0, 0, 1)))
    section = next - point
    section_length = section.length / 2
    direction = -bulge / abs(bulge)
    correction = 1
    sagitta_len = section_length * abs(bulge)
    radius = (sagitta_len**2 + section_length**2) / (2 * sagitta_len)
    if sagitta_len < radius:
        cosagitta_len = radius - sagitta_len
    else:
        cosagitta_len = sagitta_len - radius
        direction *= -1
        correction *= -1
    center = point + section / 2 + section.normalized() * cosagitta_len * rot * direction
    cp = point - center
    cn = next - center
    cr = cp.to_3d().cross(cn.to_3d()) * correction
    start = Vector((1, 0))
    if cr[2] > 0:
        angdir = 0
        startangle = -start.angle_signed(cp.to_2d())
        endangle = -start.angle_signed(cn.to_2d())
    else:
        angdir = 1
        startangle = start.angle_signed(cp.to_2d())
        endangle = start.angle_signed(cn.to_2d())
    return ArcEntity(startangle, endangle, center.to_3d(), radius, angdir)
开发者ID:fjuhec,项目名称:blender-addons,代码行数:38,代码来源:convert.py


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