Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_angle(self):
return angle_of_vector(self.get_vector())
def apply_transposed_matrix(self, transposed_matrix, **kwargs):
func = self.get_transposed_matrix_transformation(transposed_matrix)
if "path_arc" not in kwargs:
net_rotation = np.mean([
angle_of_vector(func(RIGHT)),
angle_of_vector(func(UP)) - np.pi / 2
])
kwargs["path_arc"] = net_rotation
self.apply_function(func, **kwargs)
def stop_angle(self):
return angle_of_vector(
self.points[-1] - self.get_arc_center()
) % TAU
def angle_of_tangent(self, x, graph, dx=0.01):
vect = self.input_to_graph_point(
x + dx, graph) - self.input_to_graph_point(x, graph)
return angle_of_vector(vect)
def point_at_angle(self, angle):
start_angle = angle_of_vector(
self.points[0] - self.get_center()
)
return self.point_from_proportion(
(angle - start_angle) / TAU
)
def get_angle(self):
return angle_of_vector(self.get_vector())
def put_start_and_end_on(self, start, end):
curr_start, curr_end = self.get_start_and_end()
curr_vect = curr_end - curr_start
if np.all(curr_vect == 0):
raise Exception("Cannot position endpoints of closed loop")
target_vect = end - start
self.scale(
get_norm(target_vect) / get_norm(curr_vect),
about_point=curr_start,
)
self.rotate(
angle_of_vector(target_vect) -
angle_of_vector(curr_vect),
about_point=curr_start
)
self.shift(start - curr_start)
return self
def apply_transposed_matrix(self, transposed_matrix, **kwargs):
func = self.get_transposed_matrix_transformation(transposed_matrix)
if "path_arc" not in kwargs:
net_rotation = np.mean([
angle_of_vector(func(RIGHT)),
angle_of_vector(func(UP)) - np.pi / 2
])
kwargs["path_arc"] = net_rotation
self.apply_function(func, **kwargs)
def position_tip(self, tip, at_start=False):
# Last two control points, defining both
# the end, and the tangency direction
if at_start:
anchor = self.get_start()
handle = self.get_first_handle()
else:
handle = self.get_last_handle()
anchor = self.get_end()
tip.rotate(
angle_of_vector(handle - anchor) -
PI - tip.get_angle()
)
tip.shift(anchor - tip.get_tip_point())
return tip
def get_needle_angle(self):
return angle_of_vector(
self.get_needle_tip() - self.get_center()
)