mirror of
https://github.com/3b1b/manim.git
synced 2025-08-01 17:29:06 +08:00
Vector
This commit is contained in:
@ -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
|
||||||
|
Reference in New Issue
Block a user