mirror of
https://github.com/3b1b/manim.git
synced 2025-07-31 22:13:30 +08:00
Make remove_list_redundancies keep last-most occurance of an element rather than the first occurance
This commit is contained in:
14
helpers.py
14
helpers.py
@ -199,14 +199,16 @@ def bezier(points):
|
||||
def remove_list_redundancies(l):
|
||||
"""
|
||||
Used instead of list(set(l)) to maintain order
|
||||
Keeps the last occurance of each element
|
||||
"""
|
||||
result = []
|
||||
reversed_result = []
|
||||
used = set()
|
||||
for x in l:
|
||||
for x in reversed(l):
|
||||
if not x in used:
|
||||
result.append(x)
|
||||
reversed_result.append(x)
|
||||
used.add(x)
|
||||
return result
|
||||
reversed_result.reverse()
|
||||
return reversed_result
|
||||
|
||||
def list_update(l1, l2):
|
||||
"""
|
||||
@ -649,8 +651,8 @@ def angle_between_vectors(v1, v2):
|
||||
return np.arccos(np.dot(v1,v2)/(l1*l2))
|
||||
|
||||
def project_along_vector(point, vector):
|
||||
matrix = np.eye(3) - np.outer(vector,vector)
|
||||
return np.dot(point,matrix.T)
|
||||
matrix = np.identity(3) - np.outer(vector, vector)
|
||||
return np.dot(point, matrix.T)
|
||||
|
||||
def concatenate_lists(*list_of_lists):
|
||||
return [item for l in list_of_lists for item in l]
|
||||
|
Reference in New Issue
Block a user