Skip to content

Improve line rendering performance by decreasing redundant subdivision count #3893

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Oct 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion manim/mobject/three_d/three_dimensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,12 @@ class Line3D(Cylinder):
The thickness of the line.
color
The color of the line.
resolution
The resolution of the line.
By default this value is the number of points the line will sampled at.
If you want the line to also come out checkered, use a tuple.
For example, for a line made of 24 points with 4 checker points on each
cylinder, pass the tuple (4, 24).

Examples
--------
Expand All @@ -915,9 +921,11 @@ def __init__(
end: np.ndarray = RIGHT,
thickness: float = 0.02,
color: ParsableManimColor | None = None,
resolution: int | Sequence[int] = 24,
**kwargs,
):
self.thickness = thickness
self.resolution = (2, resolution) if isinstance(resolution, int) else resolution
self.set_start_and_end_attrs(start, end, **kwargs)
if color is not None:
self.set_color(color)
Expand Down Expand Up @@ -951,6 +959,7 @@ def set_start_and_end_attrs(
height=np.linalg.norm(self.vect),
radius=self.thickness,
direction=self.direction,
resolution=self.resolution,
**kwargs,
)
self.shift((self.start + self.end) / 2)
Expand Down Expand Up @@ -1122,6 +1131,8 @@ class Arrow3D(Line3D):
The base radius of the conical tip.
color
The color of the arrow.
resolution
The resolution of the arrow line.

Examples
--------
Expand All @@ -1148,10 +1159,16 @@ def __init__(
height: float = 0.3,
base_radius: float = 0.08,
color: ParsableManimColor = WHITE,
resolution: int | Sequence[int] = 24,
**kwargs,
) -> None:
super().__init__(
start=start, end=end, thickness=thickness, color=color, **kwargs
start=start,
end=end,
thickness=thickness,
color=color,
resolution=resolution,
**kwargs,
)

self.length = np.linalg.norm(self.vect)
Expand Down
Binary file not shown.
Binary file not shown.
Binary file modified tests/test_graphical_units/control_data/threed/Arrow3D.npz
Binary file not shown.
Binary file modified tests/test_graphical_units/control_data/threed/Axes.npz
Binary file not shown.
Binary file modified tests/test_graphical_units/control_data/threed/CameraMove.npz
Binary file not shown.
Binary file not shown.
Binary file modified tests/test_graphical_units/control_data/threed/Cone.npz
Binary file not shown.
Binary file modified tests/test_graphical_units/control_data/threed/Cube.npz
Binary file not shown.
Binary file modified tests/test_graphical_units/control_data/threed/Cylinder.npz
Binary file not shown.
Binary file modified tests/test_graphical_units/control_data/threed/Dot3D.npz
Binary file not shown.
Binary file modified tests/test_graphical_units/control_data/threed/Line3D.npz
Binary file not shown.
Binary file not shown.
Binary file modified tests/test_graphical_units/control_data/threed/Sphere.npz
Binary file not shown.
Binary file not shown.
Binary file modified tests/test_graphical_units/control_data/threed/Torus.npz
Binary file not shown.
Binary file modified tests/test_graphical_units/control_data/threed/Y_Direction.npz
Binary file not shown.
Loading