Merge pull request #304 from 3b1b/quaternions

Quaternions
This commit is contained in:
Grant Sanderson 2018-09-19 10:50:58 -07:00 committed by GitHub
commit ce47c42b15
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 10 deletions

View file

@ -6496,20 +6496,22 @@ class ThumbnailP2(ThumbnailP1):
class ThumbnailOverlay(Scene):
def construct(self):
title = TextMobject("Quaternions")
title.set_width(8)
title.to_edge(UP)
title = TextMobject("Quaternions \\\\", "visualized")
title.set_width(7)
# title[1].scale(0.7, about_edge=UP)
title.to_edge(UP, buff=MED_SMALL_BUFF)
v_line = Line(DOWN, UP)
v_line.set_height(FRAME_HEIGHT)
title.set_background_stroke(color=BLACK, width=1)
rect = BackgroundRectangle(title[4:6])
rect.set_fill(opacity=1)
rect.stretch(0.9, 0)
rect.stretch(1.1, 1)
title.add_to_back(BackgroundRectangle(title[0]))
title.add_to_back(rect)
for part in (title[0][4:6], title[1][4:5]):
rect = BackgroundRectangle(part)
rect.set_fill(opacity=1)
rect.stretch(0.9, 0)
rect.stretch(1.1, 1)
title.add_to_back(rect)
# title.add_to_back(BackgroundRectangle(title[0]))
arrow = Arrow(LEFT, RIGHT)
arrow.scale(1.5)

View file

@ -43,7 +43,10 @@ def quaternion_conjugate(quaternion):
def rotate_vector(vector, angle, axis=OUT):
quat = quaternion_from_angle_axis(angle, axis)
quat_inv = quaternion_conjugate(quat)
product = reduce(quaternion_mult, [quat, np.append(0, vector), quat_inv])
product = reduce(
quaternion_mult,
[quat, np.append(0, vector), quat_inv]
)
return product[1:]