當前位置: 首頁>>代碼示例>>Python>>正文


Python Vec.rotate方法代碼示例

本文整理匯總了Python中srctools.Vec.rotate方法的典型用法代碼示例。如果您正苦於以下問題:Python Vec.rotate方法的具體用法?Python Vec.rotate怎麽用?Python Vec.rotate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在srctools.Vec的用法示例。


在下文中一共展示了Vec.rotate方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: pose

# 需要導入模塊: from srctools import Vec [as 別名]
# 或者: from srctools.Vec import rotate [as 別名]
def pose(f, rot):
    global FRAME
       
    # Calculate the piston's rotation.
    
    # First find the real position of the piston hinge.
    hinge_pos = Vec(-43, 0, 10.5)
    hinge_pos.x -= 64
    hinge_pos.rotate(float(rot), 0, 0)
    hinge_pos.x += 64
    
	# Where we want the end of the piston to be.
    anchor_point = Vec(z=-96, x=rot*1.5 + 96)
    
    piston_off = hinge_pos - anchor_point
    print(piston_off)
    piston_rot = math.degrees(math.atan2(piston_off.z, -piston_off.x))
    
    f.write(frame_temp.format(
        time=FRAME,
        rot=-round(math.radians(rot), 6),
        # Cancel the effect of rot on pist_rot
        pist_rot=round(math.radians((piston_rot + rot) % 360), 6),
        len=-piston_off.mag(),
        marker=Vec(z=anchor_point.z, y=-anchor_point.x),
    ))
    FRAME += 1
開發者ID:TeamSpen210,項目名稱:tSpenAddons-src,代碼行數:29,代碼來源:animation.py

示例2: res_camera

# 需要導入模塊: from srctools import Vec [as 別名]
# 或者: from srctools.Vec import rotate [as 別名]
def res_camera(inst: Entity, res: Property):
    """Result for the camera component.

    """
    conf = res.value
    normal = Vec(0, 0, 1).rotate_by_str(inst['angles'])
    if normal.z != 0:
        # Can't be on floor/ceiling!
        inst.remove()
        return
    base_yaw = math.degrees(math.atan2(normal.y, normal.x)) % 360
    inst['angles'] = '0 {:g} 0'.format(base_yaw)

    inst_name = inst['targetname']

    try:
        [target] = inst.map.by_target[inst_name + '-target']  # type: Entity
    except ValueError:
        # No targets with that name
        inst.remove()
        return

    for trig in inst.map.by_class['trigger_catapult']:  # type: Entity
        if trig['targetname'].startswith(inst_name):
            trig.remove()

    target_loc = Vec.from_str(target['origin'])
    target.remove()  # Not needed...

    BULLSYE_LOCS[target_loc.as_tuple()] += 1

    base_loc = Vec.from_str(inst['origin'])

    # Move three times to position the camera arms and lens.
    yaw_pos = Vec(conf['yaw_off']).rotate_by_str(inst['angles'])
    yaw_pos += base_loc

    pitch, yaw, _ = (target_loc - yaw_pos).to_angle()

    inst.map.create_ent(
        classname='func_instance',
        targetname=inst['targetname'],
        file=conf['yaw_inst'],
        angles='0 {:g} 0'.format(yaw),
        origin=yaw_pos,
    )

    pitch_pos = Vec(conf['pitch_off'])
    pitch_pos.rotate(yaw=yaw)
    pitch_pos.rotate_by_str(inst['angles'])
    pitch_pos += yaw_pos

    inst.map.create_ent(
        classname='func_instance',
        targetname=inst['targetname'],
        file=conf['pitch_inst'],
        angles='{:g} {:g} 0'.format(pitch, yaw),
        origin=pitch_pos,
    )

    cam_pos = Vec(conf['cam_off'])
    cam_pos.rotate(pitch=pitch, yaw=yaw)
    cam_pos += pitch_pos

    # Recompute, since this can be slightly different if the camera is large.
    cam_angles = (target_loc - cam_pos).to_angle()

    ALL_CAMERAS.append(Camera(inst, res.value, cam_pos, cam_angles))
開發者ID:BenVlodgi,項目名稱:BEE2.4,代碼行數:70,代碼來源:monitor.py


注:本文中的srctools.Vec.rotate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。