Merge branch 'master' into eop

This commit is contained in:
Ben Hambrecht 2018-04-19 09:44:42 +02:00
commit 276128e768
3 changed files with 1043 additions and 78 deletions

File diff suppressed because it is too large Load diff

View file

@ -226,6 +226,7 @@ class Laptop(VGroup):
body.set_fill(self.shaded_body_color, opacity=1)
body.sort_submobjects(lambda p: p[2])
body[-1].set_fill(self.body_color)
screen_plate = body.copy()
keyboard = VGroup(*[
VGroup(*[
Square(**self.key_color_kwargs)
@ -243,7 +244,6 @@ class Laptop(VGroup):
keyboard.shift(MED_SMALL_BUFF * UP)
body.add(keyboard)
screen_plate = body.copy()
screen_plate.stretch(self.screen_thickness /
self.body_dimensions[2], dim=2)
screen = Rectangle(

View file

@ -3,7 +3,7 @@ import numpy as np
from scipy import linalg
from utils.simple_functions import choose
CLOSED_THRESHOLD = 0.0
CLOSED_THRESHOLD = 0.001
def bezier(points):
@ -98,7 +98,8 @@ def get_smooth_handle_points(points):
def solve_func(b):
return linalg.solve_banded((l, u), diag, b)
if is_closed(points):
use_closed_solve_function = is_closed(points)
if use_closed_solve_function:
# Get equations to relate first and last points
matrix = diag_to_matrix((l, u), diag)
# last row handles second derivative
@ -109,11 +110,15 @@ def get_smooth_handle_points(points):
b[0] = 2 * points[0]
b[-1] = np.zeros(dim)
def solve_func(b):
def closed_curve_solve_func(b):
return linalg.solve(matrix, b)
handle_pairs = np.zeros((2 * num_handles, dim))
for i in range(dim):
handle_pairs[:, i] = solve_func(b[:, i])
if use_closed_solve_function:
handle_pairs[:, i] = closed_curve_solve_func(b[:, i])
else:
handle_pairs[:, i] = solve_func(b[:, i])
return handle_pairs[0::2], handle_pairs[1::2]