Addressed places which depended on rotate being about the origin

This commit is contained in:
Grant Sanderson
2018-01-20 13:14:17 -08:00
parent 1ffbc77eda
commit c5b0e26090
10 changed files with 22 additions and 30 deletions

View File

@ -2089,7 +2089,7 @@ class MusicExample(SampleSpaceScene, PiCreatureScene):
notes = VGroup(*[note.copy() for x in range(10)])
sine_wave = FunctionGraph(np.sin, x_min = -5, x_max = 5)
sine_wave.scale(0.75)
sine_wave.rotate(np.pi/6)
sine_wave.rotate(np.pi/6, about_point = ORIGIN)
sine_wave.shift(
notes.get_center() - \
sine_wave.point_from_proportion(0)

View File

@ -1348,7 +1348,7 @@ class IntroduceTelepathyExample(StatisticsVsEmpathy):
vect[1] = 0
arc = Arc(angle = angle)
arc.rotate(-angle/2 + angle_of_vector(vect))
arc.rotate(-angle/2 + angle_of_vector(vect), about_point = ORIGIN)
arc.scale(3)
arcs = VGroup(*[arc.copy() for x in range(n_arcs)])
arcs.move_to(pi2.eyes.get_center(), vect)

View File

@ -3072,7 +3072,7 @@ class CorrectForDependence(NameBinomial):
for value, alt_value, bar in zip(values, alt_values, bars):
arrow = arrow_template.copy()
if value < alt_value:
arrow.rotate(np.pi)
arrow.rotate(np.pi, about_point = ORIGIN)
arrow.next_to(bar, UP)
arrows.add(arrow)

View File

@ -248,16 +248,6 @@ class Mobject(object):
mob.points += about_point
return self
def do_about_point(self, point, method, *args, **kwargs):
self.shift(-point)
method(*args, **kwargs)
self.shift(point)
return self
def do_in_place(self, method, *args, **kwargs):
self.do_about_point(self.get_center(), method, *args, **kwargs)
return self
def rotate_in_place(self, angle, axis = OUT, axes = []):
# redundant with default behavior of rotate now.
return self.rotate(angle, axis = axis, axes = axes)
@ -712,7 +702,6 @@ class Mobject(object):
"""
raise Exception("Not implemented")
def align_points(self, mobject):
count1 = self.get_num_points()
count2 = mobject.get_num_points()

View File

@ -218,7 +218,7 @@ class VMobjectFromSVGPathstring(VMobject):
for command, coord_string in pairs:
self.handle_command(command, coord_string)
#people treat y-coordinate differently
self.rotate(np.pi, RIGHT)
self.rotate(np.pi, RIGHT, about_point = ORIGIN)
def handle_command(self, command, coord_string):
isLower = command.islower()

View File

@ -127,7 +127,7 @@ class DiamondFractal(SelfSimilarFractal):
# VGroup(*subparts).rotate(np.pi/4)
for part, vect in zip(subparts, compass_directions(start_vect = UP+RIGHT)):
part.next_to(ORIGIN, vect, buff = 0)
VGroup(*subparts).rotate(np.pi/4)
VGroup(*subparts).rotate(np.pi/4, about_point = ORIGIN)
class PentagonalFractal(SelfSimilarFractal):
@ -142,7 +142,7 @@ class PentagonalFractal(SelfSimilarFractal):
def arrange_subparts(self, *subparts):
for x, part in enumerate(subparts):
part.shift(0.95*part.get_height()*UP)
part.rotate(2*np.pi*x/5)
part.rotate(2*np.pi*x/5, about_point = ORIGIN)
class PentagonalPiCreatureFractal(PentagonalFractal):
def init_colors(self):
@ -163,7 +163,7 @@ class PentagonalPiCreatureFractal(PentagonalFractal):
def arrange_subparts(self, *subparts):
for part in subparts:
part.rotate(2*np.pi/5)
part.rotate(2*np.pi/5, about_point = ORIGIN)
PentagonalFractal.arrange_subparts(self, *subparts)
@ -236,7 +236,7 @@ class WonkyHexagonFractal(SelfSimilarFractal):
def arrange_subparts(self, *subparts):
for i, piece in enumerate(subparts):
piece.rotate(i*np.pi/12)
piece.rotate(i*np.pi/12, about_point = ORIGIN)
p1, p2, p3, p4, p5, p6, p7 = subparts
center_row = VGroup(p1, p4, p7)
center_row.arrange_submobjects(RIGHT, buff = 0)
@ -265,7 +265,7 @@ class CircularFractal(SelfSimilarFractal):
ORIGIN, UP,
buff = self.height/(2*np.tan(theta))
)
part.rotate(i*2*np.pi/self.num_subparts)
part.rotate(i*2*np.pi/self.num_subparts, about_point = ORIGIN)
self.num_subparts -= 1
@ -548,7 +548,7 @@ class FlowSnake(LindenmayerCurve):
}
def __init__(self, **kwargs):
LindenmayerCurve.__init__(self, **kwargs)
self.rotate(-self.order*np.pi/9)
self.rotate(-self.order*np.pi/9, about_point = ORIGIN)
class SierpinskiCurve(LindenmayerCurve):
CONFIG = {

View File

@ -260,7 +260,7 @@ class GraphScene(Scene):
def annotate_edges(self, mobject, fade_in = True, **kwargs):
angles = map(np.arctan, map(Line.get_slope, self.edges))
self.edge_annotations = [
mobject.copy().rotate(angle).shift(edge.get_center())
mobject.copy().rotate(angle).move_to(edge.get_center())
for angle, edge in zip(angles, self.edges)
]
if fade_in:

View File

@ -169,12 +169,15 @@ class Axes(VGroup):
VGroup.__init__(self, **kwargs)
self.x_axis = self.get_axis(self.x_min, self.x_max, self.x_axis_config)
self.y_axis = self.get_axis(self.y_min, self.y_max, self.y_axis_config)
self.y_axis.rotate(np.pi/2)
self.y_axis.rotate(np.pi/2, about_point = ORIGIN)
self.add(self.x_axis, self.y_axis)
if self.three_d:
self.z_axis = self.get_axis(self.z_min, self.z_max, self.z_axis_config)
self.z_axis.rotate(-np.pi/2, UP)
self.z_axis.rotate(angle_of_vector(self.z_normal), OUT)
self.z_axis.rotate(-np.pi/2, UP, about_point = ORIGIN)
self.z_axis.rotate(
angle_of_vector(self.z_normal), OUT,
about_point = ORIGIN
)
self.add(self.z_axis)
def get_axis(self, min_val, max_val, extra_config):

View File

@ -94,7 +94,7 @@ class Speedometer(VMobject):
)
needle.stretch_to_fit_width(self.needle_width)
needle.stretch_to_fit_height(self.needle_height)
needle.rotate(start_angle - np.pi/2)
needle.rotate(start_angle - np.pi/2, about_point = ORIGIN)
self.add(needle)
self.needle = needle
@ -245,8 +245,8 @@ class Laptop(VGroup):
self.axis = axis
self.add(body, screen_plate, axis)
self.rotate(5*np.pi/12, LEFT)
self.rotate(np.pi/6, DOWN)
self.rotate(5*np.pi/12, LEFT, about_point = ORIGIN)
self.rotate(np.pi/6, DOWN, about_point = ORIGIN)
class PatreonLogo(SVGMobject):
CONFIG = {

View File

@ -104,12 +104,12 @@ class VectorScene(Scene):
angle = vector.get_angle()
if not rotate:
label.rotate(-angle)
label.rotate(-angle, about_point = ORIGIN)
if direction is "left":
label.shift(-label.get_bottom() + 0.1*UP)
else:
label.shift(-label.get_top() + 0.1*DOWN)
label.rotate(angle)
label.rotate(angle, about_point = ORIGIN)
label.shift((vector.get_end() - vector.get_start())/2)
return label