本文整理汇总了Python中utils.Vec.axis方法的典型用法代码示例。如果您正苦于以下问题:Python Vec.axis方法的具体用法?Python Vec.axis怎么用?Python Vec.axis使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类utils.Vec
的用法示例。
在下文中一共展示了Vec.axis方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: make_ubend
# 需要导入模块: from utils import Vec [as 别名]
# 或者: from utils.Vec import axis [as 别名]
def make_ubend(
origin_a: Vec,
origin_b: Vec,
normal: Vec,
config,
max_size: int,
is_start=False,
):
"""Create u-shaped bends."""
offset = origin_b - origin_a
out_axis = normal.axis()
out_off = offset[out_axis]
offset[out_axis] = 0
if len(offset) == 2:
# Len counts the non-zero values..
# If 2, the ubend is diagonal so it's ambigous where to put the bends.
return []
side_norm = offset.norm()
for side_axis, side_dist in zip('xyz', offset):
if side_dist:
side_dist = abs(side_dist) + 128
break
else:
# The two tube items are on top of another, that's
# impossible to generate.
return []
# Calculate the size of the various parts.
# first/second _size = size of the corners.
# first/second _straight = length of straight sections
# off_straight = length of straight in between corners
if out_off == 0:
# Both tubes are parallel to each other - use half the distance
# for the bends.
first_size = second_size = min(
3,
max_size,
side_dist // (128 * 2),
)
first_straight = second_straight = 0
side_straight = side_dist - 2 * 128 * first_size
elif out_off > 0:
# The second tube is further away than the first - the first bend
# should be largest.
# We need 1 spot for the second bend.
first_size = min(
3,
max_size,
side_dist // 128 - 1,
out_off,
)
second_size = min(3, side_dist // 128 - first_size, max_size)
first_straight = (out_off + 128) - 128 * second_size
second_straight = (first_size - second_size) * 128
side_straight = (side_dist / 128 - first_size - second_size) * 128
elif out_off < 0:
# The first tube is further away than the second - the second bend
# should be largest.
second_size = min(
3,
max_size,
side_dist // 128 - 1,
-out_off # -out = abs()
)
first_size = min(3, side_dist // 128 - second_size, max_size)
first_straight = (second_size - first_size) * 128
second_straight = (-out_off + 128) - 128 * second_size
side_straight = (side_dist / 128 - first_size - second_size) * 128
else:
return [] # Not possible..
# We always have a straight segment at the first marker point - move
# everything up slightly.
first_straight += 128
LOGGER.info(
'Ubend {}: {}, c={}, {}, c={}, {}',
out_off,
first_straight,
first_size,
side_straight,
second_size,
second_straight,
)
make_straight(
origin_a,
normal,
first_straight,
config,
#.........这里部分代码省略.........