def setup_xy(self, p1_world, p2_world, p1_ucs, p2_ucs):
""" setup an UCS given by the points p1 and p2
only xy-plane, z' = z
"""
ucs_angle_to_x_axis = get_angle(p1_ucs, p2_ucs)
world_angle_to_x_axis = get_angle(p1_world, p2_world)
rotation = normalize_angle(world_angle_to_x_axis - ucs_angle_to_x_axis)
self._xaxis = (math.cos(rotation), math.sin(rotation), 0.)
self._yaxis = (math.cos(rotation+HALF_PI), math.sin(rotation+HALF_PI), 0.)
self._zaxis = (0., 0., 1.)
ucs_angle_to_x_axis = get_angle((0., 0.), p1_ucs)
world_angle_to_x_axis = rotation + ucs_angle_to_x_axis
distance_from_ucs_origin = math.hypot(p1_ucs[0], p1_ucs[1])
delta_x = distance_from_ucs_origin * math.cos(world_angle_to_x_axis)
delta_y = distance_from_ucs_origin * math.sin(world_angle_to_x_axis)
self._origin = (p1_world[0] - delta_x, p1_world[1] - delta_y, 0.)
评论列表
文章目录