mirror of
https://github.com/3b1b/manim.git
synced 2025-11-14 12:27:44 +00:00
Added Line.get_unit_vector
This commit is contained in:
parent
a443ddc8f2
commit
0b290a19b9
1 changed files with 8 additions and 0 deletions
|
|
@ -368,6 +368,14 @@ class Line(VMobject):
|
|||
def get_vector(self):
|
||||
return self.get_end() - self.get_start()
|
||||
|
||||
def get_unit_vector(self):
|
||||
vect = self.get_vector()
|
||||
norm = np.linalg.norm(vect)
|
||||
if norm == 0:
|
||||
# TODO, is this the behavior I want?
|
||||
return np.array(ORIGIN)
|
||||
return vect / norm
|
||||
|
||||
def get_start(self):
|
||||
return np.array(self.points[0])
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue