mirror of
https://github.com/3b1b/manim.git
synced 2025-08-05 16:49:03 +00:00
Vector
This commit is contained in:
parent
c19b313808
commit
b7e53a0e8b
1 changed files with 13 additions and 1 deletions
|
@ -121,6 +121,18 @@ class Arrow(Line):
|
||||||
setattr(self, attr, getattr(self, attr)[:-self.num_tip_points])
|
setattr(self, attr, getattr(self, attr)[:-self.num_tip_points])
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
class Vector(Arrow):
|
||||||
|
CONFIG = {
|
||||||
|
"color" : WHITE,
|
||||||
|
"buff" : 0,
|
||||||
|
}
|
||||||
|
def __init__(self, start, direction, **kwargs):
|
||||||
|
if isinstance(start, Mobject):
|
||||||
|
end = start.get_center()+direction
|
||||||
|
else:
|
||||||
|
end = start + direction
|
||||||
|
Arrow.__init__(self, start, end, **kwargs)
|
||||||
|
|
||||||
class CurvedLine(Line):
|
class CurvedLine(Line):
|
||||||
def __init__(self, start, end, via = None, **kwargs):
|
def __init__(self, start, end, via = None, **kwargs):
|
||||||
self.set_start_and_end(start, end)
|
self.set_start_and_end(start, end)
|
||||||
|
@ -233,7 +245,7 @@ class Rectangle(Grid):
|
||||||
Grid.__init__(self, 1, 1, **kwargs)
|
Grid.__init__(self, 1, 1, **kwargs)
|
||||||
|
|
||||||
def generate_points(self):
|
def generate_points(self):
|
||||||
hw = [self.width/2.0, self.height/2.0]
|
hw = [self.height/2.0, self.width/2.0]
|
||||||
self.add_points([
|
self.add_points([
|
||||||
(x, u, 0) if dim==1 else (u, x, 0)
|
(x, u, 0) if dim==1 else (u, x, 0)
|
||||||
for dim in 0, 1
|
for dim in 0, 1
|
||||||
|
|
Loading…
Add table
Reference in a new issue