本文整理汇总了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
示例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))