本文整理匯總了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,
#.........這裏部分代碼省略.........