Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/3b1b/manim
Browse files Browse the repository at this point in the history
  • Loading branch information
TonyCrane committed Jul 28, 2021
2 parents 4d65c97 + 152d03e commit f090920
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 13 deletions.
4 changes: 2 additions & 2 deletions manimlib/mobject/coordinate_systems.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class CoordinateSystem():
"y_range": np.array([-4.0, 4.0, 1.0]),
"width": None,
"height": None,
"num_sampled_graph_points_per_tick": 5,
"num_sampled_graph_points_per_tick": 20,
}

def coords_to_point(self, *coords):
Expand Down Expand Up @@ -404,7 +404,7 @@ class NumberPlane(Axes):
"width": None,
# Defaults to a faded version of line_config
"faded_line_style": None,
"faded_line_ratio": 1,
"faded_line_ratio": 4,
"make_smooth_after_applying_functions": True,
}

Expand Down
4 changes: 2 additions & 2 deletions manimlib/mobject/three_dimensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class SurfaceMesh(VGroup):
CONFIG = {
"resolution": (21, 21),
"stroke_width": 1,
"normal_nudge": 1e-2,
"normal_nudge": 1e-3,
"depth_test": True,
"flat_stroke": False,
}
Expand All @@ -35,7 +35,7 @@ def init_points(self):

points, du_points, dv_points = uv_surface.get_surface_points_and_nudged_points()
normals = uv_surface.get_unit_normals()
nudge = 1e-2
nudge = self.normal_nudge
nudged_points = points + nudge * normals

for ui in u_indices:
Expand Down
10 changes: 8 additions & 2 deletions manimlib/mobject/types/dot_cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
import moderngl

from manimlib.constants import GREY_C
from manimlib.constants import ORIGIN
from manimlib.mobject.types.point_cloud_mobject import PMobject
from manimlib.utils.iterables import resize_preserving_order


DEFAULT_DOT_CLOUD_RADIUS = 0.05
DEFAULT_DOT_RADIUS = 0.05
DEFAULT_GRID_HEIGHT = 6
DEFAULT_BUFF_RATIO = 0.5

Expand All @@ -15,7 +16,7 @@ class DotCloud(PMobject):
CONFIG = {
"color": GREY_C,
"opacity": 1,
"radius": DEFAULT_DOT_CLOUD_RADIUS,
"radius": DEFAULT_DOT_RADIUS,
"shader_folder": "true_dot",
"render_primitive": moderngl.POINTS,
"shader_dtype": [
Expand Down Expand Up @@ -106,3 +107,8 @@ def get_shader_data(self):
self.read_data_to_shader(shader_data, "radius", "radii")
self.read_data_to_shader(shader_data, "color", "rgbas")
return shader_data


class TrueDot(DotCloud):
def __init__(self, center=ORIGIN, radius=DEFAULT_DOT_RADIUS, **kwargs):
super().__init__(points=[center], radius=radius, **kwargs)
4 changes: 2 additions & 2 deletions manimlib/mobject/types/surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ def get_shader_vert_indices(self):


class ParametricSurface(Surface):
def __init__(self, uv_func, **kwargs):
def __init__(self, uv_func, u_range=(0, 1), v_range=(0, 1), **kwargs):
self.passed_uv_func = uv_func
super().__init__(**kwargs)
super().__init__(u_range=u_range, v_range=v_range, **kwargs)

def uv_func(self, u, v):
return self.passed_uv_func(u, v)
Expand Down
1 change: 1 addition & 0 deletions manimlib/scene/three_d_scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class ThreeDScene(Scene):
CONFIG = {
"camera_config": {
"samples": 4,
"anti_alias_width": 0,
}
}

Expand Down
10 changes: 5 additions & 5 deletions manimlib/utils/space_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,19 +365,19 @@ def earclip_triangulation(verts, ring_ends):
]

def is_in(point, ring_id):
return abs(abs(get_winding_number([i-point for i in verts[rings[ring_id]]]))-1)<1e-5
return abs(abs(get_winding_number([i - point for i in verts[rings[ring_id]]])) - 1) < 1e-5

def ring_area(ring_id):
ring = rings[ring_id]
s = 0
for i, j in zip(ring[1:], ring):
s += cross2d(verts[i], verts[j])
return abs(s)/2
return abs(s) / 2

# Points at the same position may cause problems
for i in rings:
verts[i[0]] += (verts[i[1]]-verts[i[0]])*1e-6
verts[i[-1]] += (verts[i[-2]]-verts[i[-1]])*1e-6
verts[i[0]] += (verts[i[1]]-verts[i[0]]) * 1e-6
verts[i[-1]] += (verts[i[-2]]-verts[i[-1]]) * 1e-6

# First, we should know which rings are directly contained in it for each ring

Expand Down Expand Up @@ -407,7 +407,7 @@ def is_in_fast(ring_a, ring_b):
res = []

# Then, we can use earcut for each part
used = [False]*len(rings)
used = [False] * len(rings)
for i in rings_sorted:
if used[i]:
continue
Expand Down

0 comments on commit f090920

Please sign in to comment.