Dataset Viewer
Auto-converted to Parquet
file_path
stringlengths
32
71
content
stringlengths
0
7.98k
manim-physics_Matheart/.readthedocs.yml
version: 2 build: os: ubuntu-22.04 tools: python: "3.10" apt_packages: - libpango1.0-dev - ffmpeg - graphviz python: install: - requirements: docs/rtd-requirements.txt - requirements: docs/requirements.txt - method: pip path: .
manim-physics_Matheart/README.md
# manim-physics ## Introduction This is a 2D physics simulation plugin that allows you to generate complicated scenes in various branches of Physics such as rigid mechanics, electromagnetism, wave etc. **Due to some reason, I (Matheart) may not have time to maintain this repo, if you want to contribute please seek help from other contributors.** Official Documentation: https://manim-physics.readthedocs.io/en/latest/ Contributors: - [**pdcxs**](https://github.com/pdcxs) - [**Matheart**](https://github.com/Matheart) - [**icedcoffeeee**](https://github.com/icedcoffeeee) # Installation `manim-physics` is a package on pypi, and can be directly installed using pip: ```bash pip install manim-physics ```
manim-physics_Matheart/example.py
from manim_physics import * class MagneticFieldExample(ThreeDScene): def construct(self): wire = Wire(Circle(2).rotate(PI / 2, UP)) mag_field = MagneticField(wire) self.set_camera_orientation(PI / 3, PI / 4) self.add(wire, mag_field)
manim-physics_Matheart/.github/workflows/ci.yml
name: CI concurrency: group: ${{ github.ref }} cancel-in-progress: true on: push: branches: - main pull_request: branches: - main jobs: test: runs-on: ${{ matrix.os }} env: DISPLAY: :0 PYTEST_ADDOPTS: "--color=yes" # colors in pytest strategy: fail-fast: false matrix: os: [ubuntu-22.04, macos-latest, windows-latest] python: ["3.8", "3.9", "3.10", "3.11"] steps: - name: Checkout the repository uses: actions/checkout@v3 - name: Install Poetry run: | pipx install poetry poetry config virtualenvs.prefer-active-python true - name: Setup Python ${{ matrix.python }} uses: actions/setup-python@v4 with: python-version: ${{ matrix.python }} cache: "poetry" - name: Setup macOS PATH if: runner.os == 'macOS' run: | echo "$HOME/.local/bin" >> $GITHUB_PATH - name: Setup cache variables shell: bash id: cache-vars run: | echo "date=$(/bin/date -u "+%m%w%Y")" >> $GITHUB_OUTPUT - name: Install and cache ffmpeg (all OS) uses: FedericoCarboni/setup-ffmpeg@v2 with: token: ${{ secrets.GITHUB_TOKEN }} id: setup-ffmpeg - name: Install system dependencies (Linux) if: runner.os == 'Linux' uses: awalsh128/cache-apt-pkgs-action@latest with: packages: python3-opengl libpango1.0-dev xvfb version: 1.0 - name: Install Texlive (Linux) if: runner.os == 'Linux' uses: teatimeguest/setup-texlive-action@v2 with: cache: true packages: scheme-basic fontspec inputenc fontenc tipa mathrsfs calligra xcolor standalone preview doublestroke ms everysel setspace rsfs relsize ragged2e fundus-calligra microtype wasysym physics dvisvgm jknapltx wasy cm-super babel-english gnu-freefont mathastext cbfonts-fd - name: Start virtual display (Linux) if: runner.os == 'Linux' run: | # start xvfb in background sudo /usr/bin/Xvfb $DISPLAY -screen 0 1280x1024x24 & - name: Setup macOS cache uses: actions/cache@v3 id: cache-macos if: runner.os == 'macOS' with: path: ${{ github.workspace }}/macos-cache key: ${{ runner.os }}-dependencies-tinytex-${{ hashFiles('.github/manimdependency.json') }}-${{ steps.cache-vars.outputs.date }}-1 - name: Install system dependencies (MacOS) if: runner.os == 'macOS' && steps.cache-macos.outputs.cache-hit != 'true' run: | tinyTexPackages=$(python -c "import json;print(' '.join(json.load(open('.github/manimdependency.json'))['macos']['tinytex']))") IFS=' ' read -a ttp <<< "$tinyTexPackages" oriPath=$PATH sudo mkdir -p $PWD/macos-cache echo "Install TinyTeX" sudo curl -L -o "/tmp/TinyTeX.tgz" "https://github.com/yihui/tinytex-releases/releases/download/daily/TinyTeX-1.tgz" sudo tar zxf "/tmp/TinyTeX.tgz" -C "$PWD/macos-cache" export PATH="$PWD/macos-cache/TinyTeX/bin/universal-darwin:$PATH" sudo tlmgr update --self for i in "${ttp[@]}"; do sudo tlmgr install "$i" done export PATH="$oriPath" echo "Completed TinyTeX" - name: Install cairo (MacOS) if: runner.os == 'macOS' run: brew install cairo - name: Add macOS dependencies to PATH if: runner.os == 'macOS' shell: bash run: | echo "/Library/TeX/texbin" >> $GITHUB_PATH echo "$HOME/.poetry/bin" >> $GITHUB_PATH echo "$PWD/macos-cache/TinyTeX/bin/universal-darwin" >> $GITHUB_PATH - name: Setup Windows cache id: cache-windows if: runner.os == 'Windows' uses: actions/cache@v3 with: path: ${{ github.workspace }}\ManimCache key: ${{ runner.os }}-dependencies-tinytex-${{ hashFiles('.github/manimdependency.json') }}-${{ steps.cache-vars.outputs.date }}-1 - uses: ssciwr/setup-mesa-dist-win@v1 - name: Install system dependencies (Windows) if: runner.os == 'Windows' && steps.cache-windows.outputs.cache-hit != 'true' run: | $tinyTexPackages = $(python -c "import json;print(' '.join(json.load(open('.github/manimdependency.json'))['windows']['tinytex']))") -Split ' ' $OriPath = $env:PATH echo "Install Tinytex" Invoke-WebRequest "https://github.com/yihui/tinytex-releases/releases/download/daily/TinyTeX-1.zip" -O "$($env:TMP)\TinyTex.zip" Expand-Archive -LiteralPath "$($env:TMP)\TinyTex.zip" -DestinationPath "$($PWD)\ManimCache\LatexWindows" $env:Path = "$($PWD)\ManimCache\LatexWindows\TinyTeX\bin\windows;$($env:PATH)" tlmgr update --self foreach ($c in $tinyTexPackages){ $c=$c.Trim() tlmgr install $c } $env:PATH=$OriPath echo "Completed Latex" - name: Add Windows dependencies to PATH if: runner.os == 'Windows' run: | $env:Path += ";" + "$($PWD)\ManimCache\LatexWindows\TinyTeX\bin\windows" $env:Path = "$env:USERPROFILE\.poetry\bin;$($env:PATH)" echo "$env:Path" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append - name: Install manim run: | poetry install --with dev - name: Run tests run: | poetry run python -m pytest
manim-physics_Matheart/manim_physics/__init__.py
__version__ = "0.2.3" from manim import * from .electromagnetism.electrostatics import * from .electromagnetism.magnetostatics import * from .optics.lenses import * from .optics.rays import * from .rigid_mechanics.pendulum import * from .rigid_mechanics.rigid_mechanics import * from .wave import *
manim-physics_Matheart/manim_physics/wave.py
"""3D and 2D Waves module.""" from __future__ import annotations from typing import Iterable, Optional from manim import * __all__ = [ "LinearWave", "RadialWave", "StandingWave", ] try: # For manim < 0.15.0 from manim.mobject.opengl_compatibility import ConvertToOpenGL except ModuleNotFoundError: # For manim >= 0.15.0 from manim.mobject.opengl.opengl_compatibility import ConvertToOpenGL class RadialWave(Surface, metaclass=ConvertToOpenGL): def __init__( self, *sources: Optional[np.ndarray], wavelength: float = 1, period: float = 1, amplitude: float = 0.1, x_range: Iterable[float] = [-5, 5], y_range: Iterable[float] = [-5, 5], **kwargs, ) -> None: """A 3D Surface with waves moving radially. Parameters ---------- sources The sources of disturbance. wavelength The wavelength of the wave. period The period of the wave. amplitude The amplitude of the wave. x_range The range of the wave in the x direction. y_range The range of the wave in the y direction. kwargs Additional parameters to be passed to :class:`~Surface`. Examples -------- .. manim:: RadialWaveExampleScene class RadialWaveExampleScene(ThreeDScene): def construct(self): self.set_camera_orientation(60 * DEGREES, -45 * DEGREES) wave = RadialWave( LEFT * 2 + DOWN * 5, # Two source of waves RIGHT * 2 + DOWN * 5, checkerboard_colors=[BLUE_D], stroke_width=0, ) self.add(wave) wave.start_wave() self.wait() wave.stop_wave() """ self.wavelength = wavelength self.period = period self.amplitude = amplitude self.time = 0 self.kwargs = kwargs self.sources = sources super().__init__( lambda u, v: np.array([u, v, self._wave_z(u, v, sources)]), u_range=x_range, v_range=y_range, **kwargs, ) def _wave_z(self, u: float, v: float, sources: Iterable[np.ndarray]) -> float: z = 0 for source in sources: x0, y0, _ = source z += self.amplitude * np.sin( (2 * PI / self.wavelength) * ((u - x0) ** 2 + (v - y0) ** 2) ** 0.5 - 2 * PI * self.time / self.period ) return z def _update_wave(self, mob: Mobject, dt: float) -> None: self.time += dt mob.match_points( Surface( lambda u, v: np.array([u, v, self._wave_z(u, v, self.sources)]), u_range=self.u_range, v_range=self.v_range, **self.kwargs, ) ) def start_wave(self): """Animate the wave propagation.""" self.add_updater(self._update_wave) def stop_wave(self): """Stop animating the wave propagation.""" self.remove_updater(self._update_wave) class LinearWave(RadialWave): def __init__( self, wavelength: float = 1, period: float = 1, amplitude: float = 0.1, x_range: Iterable[float] = [-5, 5], y_range: Iterable[float] = [-5, 5], **kwargs, ) -> None: """A 3D Surface with waves in one direction. Parameters ---------- wavelength The wavelength of the wave. period The period of the wave. amplitude The amplitude of the wave. x_range The range of the wave in the x direction. y_range The range of the wave in the y direction. kwargs Additional parameters to be passed to :class:`~Surface`. Examples -------- .. manim:: LinearWaveExampleScene class LinearWaveExampleScene(ThreeDScene): def construct(self): self.set_camera_orientation(60 * DEGREES, -45 * DEGREES) wave = LinearWave() self.add(wave) wave.start_wave() self.wait() wave.stop_wave() """ super().__init__( ORIGIN, wavelength=wavelength, period=period, amplitude=amplitude, x_range=x_range, y_range=y_range, **kwargs, ) def _wave_z(self, u: float, v: float, sources: Iterable[np.ndarray]) -> float: return self.amplitude * np.sin( (2 * PI / self.wavelength) * u - 2 * PI * self.time / self.period ) class StandingWave(ParametricFunction): def __init__( self, n: int = 2, length: float = 4, period: float = 1, amplitude: float = 1, **kwargs, ) -> None: """A 2D standing wave. Parameters ---------- n Harmonic number. length The length of the wave. period The time taken for one full oscillation. amplitude The maximum height of the wave. kwargs Additional parameters to be passed to :class:`~ParametricFunction`. Examples -------- .. manim:: StandingWaveExampleScene from manim_physics import * class StandingWaveExampleScene(Scene): def construct(self): wave1 = StandingWave(1) wave2 = StandingWave(2) wave3 = StandingWave(3) wave4 = StandingWave(4) waves = VGroup(wave1, wave2, wave3, wave4) waves.arrange(DOWN).move_to(ORIGIN) self.add(waves) for wave in waves: wave.start_wave() self.wait() """ self.n = n self.length = length self.period = period self.amplitude = amplitude self.time = 0 self.kwargs = {**kwargs} super().__init__( lambda t: np.array([t, amplitude * np.sin(n * PI * t / length), 0]), t_range=[0, length], **kwargs, ) self.shift([-self.length / 2, 0, 0]) def _update_wave(self, mob: Mobject, dt: float) -> None: self.time += dt mob.become( ParametricFunction( lambda t: np.array( [ t, self.amplitude * np.sin(self.n * PI * t / self.length) * np.cos(2 * PI * self.time / self.period), 0, ] ), t_range=[0, self.length], **self.kwargs, ).shift(self.wave_center + [-self.length / 2, 0, 0]) ) def start_wave(self): self.wave_center = self.get_center() self.add_updater(self._update_wave) def stop_wave(self): self.remove_updater(self._update_wave)
manim-physics_Matheart/manim_physics/optics/__init__.py
"""A lensing module. Currently only shows refraction in lenses and not total internal reflection. """
manim-physics_Matheart/manim_physics/optics/rays.py
"""Rays of light. Refracted by Lenses.""" from __future__ import annotations from typing import Iterable from manim import config from manim.mobject.geometry.line import Line from manim.utils.space_ops import angle_of_vector, rotate_vector import numpy as np from .lenses import Lens, antisnell, intersection, snell __all__ = [ "Ray", ] class Ray(Line): def __init__( self, start: Iterable[float], direction: Iterable[float], init_length: float = 5, propagate: Iterable[Lens] | None = None, **kwargs, ) -> None: """A light ray. Parameters ---------- start The start point of the ray direction The direction of the ray init_length The initial length of the ray. Once propagated, the length are lengthened to showcase lensing. propagate A list of lenses to propagate through. Example ------- .. manim:: RayExampleScene :save_last_frame: from manim_physics import * class RayExampleScene(Scene): def construct(self): lens_style = {"fill_opacity": 0.5, "color": BLUE} a = Lens(-5, 1, **lens_style).shift(LEFT) a2 = Lens(5, 1, **lens_style).shift(RIGHT) b = [ Ray(LEFT * 5 + UP * i, RIGHT, 8, [a, a2], color=RED) for i in np.linspace(-2, 2, 10) ] self.add(a, a2, *b) """ self.init_length = init_length self.propagated = False super().__init__(start, start + direction * init_length, **kwargs) if propagate: self.propagate(*propagate) def propagate(self, *lenses: Lens) -> None: """Let the ray propagate through the list of lenses passed. Parameters ---------- lenses All the lenses for the ray to propagate through """ # TODO: make modular(?) Clean up logic sorted_lens = self._sort_lens(lenses) for lens in sorted_lens: intersects = intersection(lens, self) if len(intersects) == 0: continue intersects = self._sort_intersections(intersects) if not self.propagated: self.put_start_and_end_on( self.start, intersects[1], ) else: nppcc = ( self.n_points_per_cubic_curve if config.renderer != "opengl" else self.n_points_per_curve ) self.points = self.points[:-nppcc] self.add_line_to(intersects[1]) self.end = intersects[1] i_ang = angle_of_vector(self.end - lens.C[0]) i_ang -= angle_of_vector(self.start - self.end) r_ang = snell(i_ang, lens.n) r_ang *= -1 if lens.f > 0 else 1 ref_ray = rotate_vector(lens.C[0] - self.end, r_ang) intersects = intersection( lens, Line( self.end - ref_ray * self.init_length, self.end + ref_ray * self.init_length, ), ) intersects = self._sort_intersections(intersects) self.add_line_to(intersects[1]) self.start = self.end self.end = intersects[1] i_ang = angle_of_vector(self.end - lens.C[1]) i_ang -= angle_of_vector(self.start - self.end) if np.abs(np.sin(i_ang)) < 1 / lens.n: r_ang = antisnell(i_ang, lens.n) r_ang *= -1 if lens.f < 0 else 1 ref_ray = rotate_vector(lens.C[1] - self.end, r_ang) ref_ray *= -1 if lens.f > 0 else 1 self.add_line_to(self.end + ref_ray * self.init_length) self.start = self.end self.end = self.get_end() self.propagated = True def _sort_lens(self, lenses: Iterable[Lens]) -> Iterable[Lens]: dists = [] for lens in lenses: try: dists += [ [np.linalg.norm(intersection(self, lens)[0] - self.start), lens] ] except: dists += [[np.inf, lens]] dists.sort(key=lambda x: x[0]) return np.array(dists, dtype=object)[:, 1] def _sort_intersections( self, intersections: Iterable[Iterable[float]] ) -> Iterable[Iterable[float]]: result = [] for inters in intersections: result.append([np.linalg.norm(inters - self.end), inters]) result.sort(key=lambda x: x[0]) return np.array(result, dtype=object)[:, 1]
manim-physics_Matheart/manim_physics/optics/lenses.py
"""Lenses for refracting Rays. """ from __future__ import annotations from typing import Iterable, Tuple from manim import config from manim.constants import LEFT, RIGHT from manim.mobject.geometry.arc import Circle from manim.mobject.geometry.boolean_ops import Difference, Intersection from manim.mobject.geometry.polygram import Square from manim.mobject.types.vectorized_mobject import VMobject, VectorizedPoint import numpy as np from shapely import geometry as gm __all__ = ["Lens"] try: # For manim < 0.15.0 from manim.mobject.opengl_compatibility import ConvertToOpenGL except ModuleNotFoundError: # For manim >= 0.15.0 from manim.mobject.opengl.opengl_compatibility import ConvertToOpenGL def intersection(vmob1: VMobject, vmob2: VMobject) -> Iterable[Iterable[float]]: """intersection points of 2 curves""" a = gm.LineString(vmob1.points) b = gm.LineString(vmob2.points) intersects: gm.GeometryCollection = a.intersection(b) try: # for intersections > 1 return np.array( [[[x, y, z] for x, y, z in m.coords][0] for m in intersects.geoms] ) except: # else return np.array([[x, y, z] for x, y, z in intersects.coords]) def snell(i_ang: float, n: float) -> float: """accepts radians, returns radians""" return np.arcsin(np.sin(i_ang) / n) def antisnell(r_ang: float, n: float) -> float: """accepts radians, returns radians""" return np.arcsin(np.sin(r_ang) * n) class Lens(VMobject, metaclass=ConvertToOpenGL): def __init__(self, f: float, d: float, n: float = 1.52, **kwargs) -> None: """A lens. Commonly used with :class:`~Ray` . Parameters ---------- f Focal length. This does not correspond correctly to the point of focus (Known issue). Positive f returns a convex lens, negative for concave. d Lens thickness n Refractive index. By default, glass. kwargs Additional parameters to be passed to :class:`~VMobject` . """ super().__init__(**kwargs) self.f = f f *= 50 / 7 * f if f > 0 else -50 / 7 * f # this is odd, but it works if f > 0: r = ((n - 1) ** 2 * f * d / n) ** 0.5 else: r = ((n - 1) ** 2 * -f * d / n) ** 0.5 self.d = d self.n = n self.r = r if f > 0: self.set_points( Intersection( a := Circle(r).shift(RIGHT * (r - d / 2)), b := Circle(r).shift(LEFT * (r - d / 2)), ) .insert_n_curves(50) .points ) else: self.set_points( Difference( Difference( Square(2 * 0.7 * r), a := Circle(r).shift(LEFT * (r + d / 2)), ), b := Circle(r).shift(RIGHT * (r + d / 2)), ) .insert_n_curves(50) .points ) self.add(VectorizedPoint(a.get_center()), VectorizedPoint(b.get_center())) @property def C(self) -> Tuple[Iterable[float]]: """Returns a tuple of two points corresponding to the centers of curvature.""" i = 0 i += 1 if config.renderer != "opengl" else 0 return self[i].points[0], self[i + 1].points[0] # why is this confusing
manim-physics_Matheart/manim_physics/electromagnetism/magnetostatics.py
"""Magnetostatics module""" from __future__ import annotations import itertools as it from typing import Iterable, Tuple from manim.mobject.opengl.opengl_compatibility import ConvertToOpenGL from manim.mobject.types.vectorized_mobject import VMobject from manim.mobject.vector_field import ArrowVectorField import numpy as np __all__ = ["Wire", "MagneticField"] class Wire(VMobject, metaclass=ConvertToOpenGL): """An abstract class denoting a current carrying wire to produce a :class:`~MagneticField`. Parameters ---------- stroke The original wire ``VMobject``. The resulting wire takes its form. current The magnitude of current flowing in the wire. samples The number of segments of the wire used to create the :class:`~MagneticField`. kwargs Additional parameters passed to ``VMobject``. .. note:: See :class:`~MagneticField` for examples. """ def __init__( self, stroke: VMobject, current: float = 1, samples: int = 16, **kwargs, ): self.current = current self.samples = samples super().__init__(**kwargs) self.set_points(stroke.points) class MagneticField(ArrowVectorField): """A magnetic field. Parameters ---------- wires All wires contributing to the total field. kwargs Additional parameters to be passed to ``ArrowVectorField``. Example ------- .. manim:: MagneticFieldExample :save_last_frame: from manim_physics import * class MagneticFieldExample(ThreeDScene): def construct(self): wire = Wire(Circle(2).rotate(PI / 2, UP)) mag_field = MagneticField( wire, x_range=[-4, 4], y_range=[-4, 4], ) self.set_camera_orientation(PI / 3, PI / 4) self.add(wire, mag_field) """ def __init__(self, *wires: Wire, **kwargs): dls = [] currents = [] for wire in wires: points = [ wire.point_from_proportion(i) for i in np.linspace(0, 1, wire.samples + 1) ] dls.append(list(zip(points, points[1:]))) currents.append(wire.current) super().__init__( lambda p: MagneticField._field_func(p, dls, currents), **kwargs ) @staticmethod def _field_func( p: np.ndarray, dls: Iterable[Tuple[np.ndarray, np.ndarray]], currents: Iterable[float], ): B_field = np.zeros(3) for (r0, r1), I in it.product(*dls, currents): dl = r1 - r0 r = p - r0 dist = np.linalg.norm(r) if dist < 0.1: return np.zeros(3) B_field += np.cross(dl, r) * I / dist**4 return B_field
manim-physics_Matheart/manim_physics/electromagnetism/__init__.py
manim-physics_Matheart/manim_physics/electromagnetism/electrostatics.py
"""Electrostatics module""" from __future__ import annotations from typing import Iterable from manim import normalize from manim.constants import ORIGIN, TAU from manim.mobject.geometry.arc import Arc, Dot from manim.mobject.geometry.polygram import Rectangle from manim.mobject.types.vectorized_mobject import VGroup from manim.mobject.vector_field import ArrowVectorField from manim.utils.color import BLUE, RED, RED_A, RED_D, color_gradient import numpy as np __all__ = [ "Charge", "ElectricField", ] class Charge(VGroup): def __init__( self, magnitude: float = 1, point: np.ndarray = ORIGIN, add_glow: bool = True, **kwargs, ) -> None: """An electrostatic charge object to produce an :class:`~ElectricField`. Parameters ---------- magnitude The strength of the electrostatic charge. point The position of the charge. add_glow Whether to add a glowing effect. Adds rings of varying opacities to simulate glowing effect. kwargs Additional parameters to be passed to ``VGroup``. """ VGroup.__init__(self, **kwargs) self.magnitude = magnitude self.point = point self.radius = (abs(magnitude) * 0.4 if abs(magnitude) < 2 else 0.8) * 0.3 if magnitude > 0: label = VGroup( Rectangle(width=0.32 * 1.1, height=0.006 * 1.1).set_z_index(1), Rectangle(width=0.006 * 1.1, height=0.32 * 1.1).set_z_index(1), ) color = RED layer_colors = [RED_D, RED_A] layer_radius = 4 else: label = Rectangle(width=0.27, height=0.003) color = BLUE layer_colors = ["#3399FF", "#66B2FF"] layer_radius = 2 if add_glow: # use many arcs to simulate glowing layer_num = 80 color_list = color_gradient(layer_colors, layer_num) opacity_func = lambda t: 1500 * (1 - abs(t - 0.009) ** 0.0001) rate_func = lambda t: t**2 for i in range(layer_num): self.add( Arc( radius=layer_radius * rate_func((0.5 + i) / layer_num), angle=TAU, color=color_list[i], stroke_width=101 * (rate_func((i + 1) / layer_num) - rate_func(i / layer_num)) * layer_radius, stroke_opacity=opacity_func(rate_func(i / layer_num)), ).shift(point) ) self.add(Dot(point=self.point, radius=self.radius, color=color)) self.add(label.scale(self.radius / 0.3).shift(point)) for mob in self: mob.set_z_index(1) class ElectricField(ArrowVectorField): def __init__(self, *charges: Charge, **kwargs) -> None: """An electric field. Parameters ---------- charges The charges affecting the electric field. kwargs Additional parameters to be passed to ``ArrowVectorField``. Examples -------- .. manim:: ElectricFieldExampleScene :save_last_frame: from manim_physics import * class ElectricFieldExampleScene(Scene): def construct(self): charge1 = Charge(-1, LEFT + DOWN) charge2 = Charge(2, RIGHT + DOWN) charge3 = Charge(-1, UP) field = ElectricField(charge1, charge2, charge3) self.add(charge1, charge2, charge3) self.add(field) """ self.charges = charges positions = [] magnitudes = [] for charge in charges: positions.append(charge.get_center()) magnitudes.append(charge.magnitude) super().__init__(lambda p: self._field_func(p, positions, magnitudes), **kwargs) def _field_func( self, p: np.ndarray, positions: Iterable[np.ndarray], magnitudes: Iterable[float], ) -> np.ndarray: field_vect = np.zeros(3) for p0, mag in zip(positions, magnitudes): r = p - p0 dist = np.linalg.norm(r) if dist < 0.1: return np.zeros(3) field_vect += mag / dist**2 * normalize(r) return field_vect
manim-physics_Matheart/manim_physics/rigid_mechanics/pendulum.py
r"""Pendulums. :class:`~MultiPendulum` and :class:`~Pendulum` both stem from the :py:mod:`~rigid_mechanics` feature. """ from __future__ import annotations from typing import Iterable from manim.constants import DOWN, RIGHT, UP from manim.mobject.geometry.arc import Circle from manim.mobject.geometry.line import Line from manim.mobject.mobject import Mobject from manim.mobject.types.vectorized_mobject import VGroup from manim.utils.color import ORANGE import numpy as np import pymunk from .rigid_mechanics import SpaceScene __all__ = [ "Pendulum", "MultiPendulum", "SpaceScene", ] class MultiPendulum(VGroup): def __init__( self, *bobs: Iterable[np.ndarray], pivot_point: np.ndarray = UP * 2, rod_style: dict = {}, bob_style: dict = { "radius": 0.1, "color": ORANGE, "fill_opacity": 1, }, **kwargs, ) -> None: """A multipendulum. Parameters ---------- bobs Positions of pendulum bobs. pivot_point Position of the pivot. rod_style Parameters for ``Line``. bob_style Parameters for ``Circle``. kwargs Additional parameters for ``VGroup``. Examples -------- .. manim:: MultiPendulumExample :quality: low from manim_physics import * class MultiPendulumExample(SpaceScene): def construct(self): p = MultiPendulum(RIGHT, LEFT) self.add(p) self.make_rigid_body(*p.bobs) p.start_swinging() self.add(TracedPath(p.bobs[-1].get_center, stroke_color=BLUE)) self.wait(10) """ self.pivot_point = pivot_point self.bobs = VGroup(*[Circle(**bob_style).move_to(i) for i in bobs]) self.pins = [pivot_point] self.pins += bobs self.rods = VGroup() self.rods += Line(self.pivot_point, self.bobs[0].get_center(), **rod_style) self.rods.add( *( Line( self.bobs[i].get_center(), self.bobs[i + 1].get_center(), **rod_style, ) for i in range(len(bobs) - 1) ) ) super().__init__(**kwargs) self.add(self.rods, self.bobs) def _make_joints( self, mob1: Mobject, mob2: Mobject, spacescene: SpaceScene ) -> None: a = mob1.body if type(mob2) == np.ndarray: b = pymunk.Body(body_type=pymunk.Body.STATIC) b.position = mob2[0], mob2[1] else: b = mob2.body joint = pymunk.PinJoint(a, b) spacescene.space.space.add(joint) def _redraw_rods(self, mob: Line, pins, i): try: x, y, _ = pins[i] except: x, y = pins[i].body.position x1, y1 = pins[i + 1].body.position mob.put_start_and_end_on( RIGHT * x + UP * y, RIGHT * x1 + UP * y1, ) def start_swinging(self) -> None: """Start swinging.""" spacescene: SpaceScene = self.bobs[0].spacescene pins = [self.pivot_point] pins += self.bobs for i in range(len(pins) - 1): self._make_joints(pins[i + 1], pins[i], spacescene) self.rods[i].add_updater(lambda mob, i=i: self._redraw_rods(mob, pins, i)) def end_swinging(self) -> None: """Stop swinging.""" spacescene = self.bobs[0].spacescene spacescene.stop_rigidity(self.bobs) class Pendulum(MultiPendulum): def __init__( self, length=3.5, initial_theta=0.3, pivot_point=UP * 2, rod_style={}, bob_style={ "radius": 0.25, "color": ORANGE, "fill_opacity": 1, }, **kwargs, ): """A pendulum. Parameters ---------- length The length of the pendulum. initial_theta The initial angle of deviation. rod_style Parameters for ``Line``. bob_style Parameters for ``Circle``. kwargs Additional parameters for ``VGroup``. Examples -------- .. manim:: PendulumExample :quality: low from manim_physics import * class PendulumExample(SpaceScene): def construct(self): pends = VGroup(*[Pendulum(i) for i in np.linspace(1, 5, 7)]) self.add(pends) for p in pends: self.make_rigid_body(*p.bobs) p.start_swinging() self.wait(10) """ self.length = length self.pivot_point = pivot_point point = self.pivot_point + ( RIGHT * np.sin(initial_theta) * length + DOWN * np.cos(initial_theta) * length ) super().__init__( point, pivot_point=self.pivot_point, rod_style=rod_style, bob_style=bob_style, **kwargs, )
manim-physics_Matheart/manim_physics/rigid_mechanics/__init__.py
manim-physics_Matheart/manim_physics/rigid_mechanics/rigid_mechanics.py
"""A gravity simulation space. Most objects can be made into a rigid body (moves according to gravity and collision) or a static body (stays still within the scene). To use this feature, the :class:`~SpaceScene` must be used, to access the specific functions of the space. .. note:: * This feature utilizes the pymunk package. Although unnecessary, it might make it easier if you knew a few things on how to use it. `Official Documentation <http://www.pymunk.org/en/latest/pymunk.html>`_ `Youtube Tutorial <https://youtu.be/pRk---rdrbo>`_ * A low frame rate might cause some objects to pass static objects as they don't register collisions finely enough. Trying to increase the config frame rate might solve the problem. Examples -------- .. manim:: TwoObjectsFalling from manim_physics import * # use a SpaceScene to utilize all specific rigid-mechanics methods class TwoObjectsFalling(SpaceScene): def construct(self): circle = Circle().shift(UP) circle.set_fill(RED, 1) circle.shift(DOWN + RIGHT) rect = Square().shift(UP) rect.rotate(PI / 4) rect.set_fill(YELLOW_A, 1) rect.shift(UP * 2) rect.scale(0.5) ground = Line([-4, -3.5, 0], [4, -3.5, 0]) wall1 = Line([-4, -3.5, 0], [-4, 3.5, 0]) wall2 = Line([4, -3.5, 0], [4, 3.5, 0]) walls = VGroup(ground, wall1, wall2) self.add(walls) self.play( DrawBorderThenFill(circle), DrawBorderThenFill(rect), ) self.make_rigid_body(rect, circle) # Mobjects will move with gravity self.make_static_body(walls) # Mobjects will stay in place self.wait(5) # during wait time, the circle and rect would move according to the simulate updater """ from __future__ import annotations from typing import Tuple from manim.constants import RIGHT, UP from manim.mobject.geometry.arc import Circle from manim.mobject.geometry.line import Line from manim.mobject.geometry.polygram import Polygon, Polygram, Rectangle from manim.mobject.mobject import Group, Mobject from manim.mobject.types.vectorized_mobject import VGroup, VMobject from manim.scene.scene import Scene from manim.utils.space_ops import angle_between_vectors import numpy as np import pymunk __all__ = [ "Space", "_step", "_simulate", "get_shape", "get_angle", "SpaceScene", ] try: # For manim < 0.15.0 from manim.mobject.opengl_compatibility import ConvertToOpenGL except ModuleNotFoundError: # For manim >= 0.15.0 from manim.mobject.opengl.opengl_compatibility import ConvertToOpenGL class Space(Mobject, metaclass=ConvertToOpenGL): def __init__(self, gravity: Tuple[float, float] = (0, -9.81), **kwargs): """An Abstract object for gravity. Parameters ---------- gravity The direction and strength of gravity. """ super().__init__(**kwargs) self.space = pymunk.Space() self.space.gravity = gravity self.space.sleep_time_threshold = 5 class SpaceScene(Scene): GRAVITY: Tuple[float, float] = 0, -9.81 def __init__(self, renderer=None, **kwargs): """A basis scene for all of rigid mechanics. The gravity vector can be adjusted with ``self.GRAVITY``. """ self.space = Space(gravity=self.GRAVITY) super().__init__(renderer=renderer, **kwargs) def setup(self): """Used internally""" self.add(self.space) self.space.add_updater(_step) def add_body(self, body: Mobject): """Bodies refer to pymunk's object. This method ties Mobjects to their Bodies. """ if body.body != self.space.space.static_body: self.space.space.add(body.body) self.space.space.add(body.shape) def make_rigid_body( self, *mobs: Mobject, elasticity: float = 0.8, density: float = 1, friction: float = 0.8, ): """Make any mobject movable by gravity. Equivalent to ``Scene``'s ``add`` function. Parameters ---------- mobs The mobs to be made rigid. elasticity density friction The attributes of the mobjects in regards to interacting with other rigid and static objects. """ for mob in mobs: if not hasattr(mob, "body"): self.add(mob) mob.body = pymunk.Body() mob.body.position = mob.get_x(), mob.get_y() get_angle(mob) if not hasattr(mob, "angle"): mob.angle = 0 mob.body.angle = mob.angle get_shape(mob) mob.shape.density = density mob.shape.elasticity = elasticity mob.shape.friction = friction mob.spacescene = self self.add_body(mob) mob.add_updater(_simulate) else: if mob.body.is_sleeping: mob.body.activate() def make_static_body( self, *mobs: Mobject, elasticity: float = 1, friction: float = 0.8 ) -> None: """Make any mobject interactable by rigid objects. Parameters ---------- mobs The mobs to be made static. elasticity friction The attributes of the mobjects in regards to interacting with rigid objects. """ for mob in mobs: if isinstance(mob, VGroup or Group): return self.make_static_body(*mob) mob.body = self.space.space.static_body get_shape(mob) mob.shape.elasticity = elasticity mob.shape.friction = friction self.add_body(mob) def stop_rigidity(self, *mobs: Mobject) -> None: """Stop the mobjects rigidity""" for mob in mobs: if isinstance(mob, VGroup or Group): self.stop_rigidity(*mob) if hasattr(mob, "body"): mob.body.sleep() def _step(space, dt): space.space.step(dt) def _simulate(b): x, y = b.body.position b.move_to(x * RIGHT + y * UP) b.rotate(b.body.angle - b.angle) b.angle = b.body.angle def get_shape(mob: VMobject) -> None: """Obtains the shape of the body from the mobject""" if isinstance(mob, Circle): mob.shape = pymunk.Circle(body=mob.body, radius=mob.radius) elif isinstance(mob, Line): mob.shape = pymunk.Segment( mob.body, (mob.get_start()[0], mob.get_start()[1]), (mob.get_end()[0], mob.get_end()[1]), mob.stroke_width - 3.95, ) elif issubclass(type(mob), Rectangle): width = np.linalg.norm(mob.get_vertices()[1] - mob.get_vertices()[0]) height = np.linalg.norm(mob.get_vertices()[2] - mob.get_vertices()[1]) mob.shape = pymunk.Poly.create_box(mob.body, (width, height)) elif issubclass(type(mob), Polygram): vertices = [(a, b) for a, b, _ in mob.get_vertices() - mob.get_center()] mob.shape = pymunk.Poly(mob.body, vertices) else: mob.shape = pymunk.Poly.create_box(mob.body, (mob.width, mob.height)) def get_angle(mob: VMobject) -> None: """Obtains the angle of the body from the mobject. Used internally for updaters. """ if issubclass(type(mob), Polygon): vec1 = mob.get_vertices()[0] - mob.get_vertices()[1] vec2 = type(mob)().get_vertices()[0] - type(mob)().get_vertices()[1] mob.angle = angle_between_vectors(vec1, vec2) elif isinstance(mob, Line): mob.angle = mob.get_angle()
manim-physics_Matheart/tests/test_lensing.py
__module_test__ = "optics" from manim import * from manim.utils.testing.frames_comparison import frames_comparison from manim_physics import * @frames_comparison def test_rays_lens(scene): lens_style = {"fill_opacity": 0.5, "color": BLUE} a = Lens(-100, 1, **lens_style).shift(LEFT) a2 = Lens(100, 1, **lens_style).shift(RIGHT) b = [ Ray(LEFT * 5 + UP * i, RIGHT, 8, [a, a2], color=RED) for i in np.linspace(-2, 2, 10) ] scene.add(a, a2, *b)
manim-physics_Matheart/tests/conftest.py
from __future__ import annotations import sys from pathlib import Path import pytest from manim import config, tempconfig def pytest_addoption(parser): parser.addoption( "--skip_slow", action="store_true", default=False, help="Will skip all the slow marked tests. Slow tests are arbitrarily marked as such.", ) parser.addoption( "--show_diff", action="store_true", default=False, help="Will show a visual comparison if a graphical unit test fails.", ) parser.addoption( "--set_test", action="store_true", default=False, help="Will create the control data for EACH running tests. ", ) def pytest_configure(config): config.addinivalue_line("markers", "skip_end_to_end: mark test as end_to_end test") def pytest_collection_modifyitems(config, items): if not config.getoption("--skip_slow"): return else: slow_skip = pytest.mark.skip( reason="Slow test skipped due to --disable_slow flag.", ) for item in items: if "slow" in item.keywords: item.add_marker(slow_skip) @pytest.fixture(scope="session") def python_version(): # use the same python executable as it is running currently # rather than randomly calling using python or python3, which # may create problems. return sys.executable @pytest.fixture def reset_cfg_file(): cfgfilepath = Path(__file__).parent / "test_cli" / "manim.cfg" original = cfgfilepath.read_text() yield cfgfilepath.write_text(original) @pytest.fixture def using_opengl_renderer(): """Standard fixture for running with opengl that makes tests use a standard_config.cfg with a temp dir.""" with tempconfig({"renderer": "opengl"}): yield # as a special case needed to manually revert back to cairo # due to side effects of setting the renderer config.renderer = "cairo"
manim-physics_Matheart/tests/__init__.py
manim-physics_Matheart/tests/test_rigid_mechanics.py
__module_test__ = "rigid_mechanics" from manim import * from manim.utils.testing.frames_comparison import frames_comparison from manim_physics.rigid_mechanics.rigid_mechanics import * @frames_comparison(base_scene=SpaceScene) def test_rigid_mechanics(scene): circle = Circle().shift(UP) circle.set_fill(RED, 1) circle.shift(DOWN + RIGHT) rect = Square().shift(UP) rect.rotate(PI / 4) rect.set_fill(YELLOW_A, 1) rect.shift(UP * 2) rect.scale(0.5) ground = Line([-4, -3.5, 0], [4, -3.5, 0]) wall1 = Line([-4, -3.5, 0], [-4, 3.5, 0]) wall2 = Line([4, -3.5, 0], [4, 3.5, 0]) walls = VGroup(ground, wall1, wall2) scene.add(walls) scene.play( DrawBorderThenFill(circle), DrawBorderThenFill(rect), ) scene.make_rigid_body(rect, circle) scene.make_static_body(walls) scene.wait()
manim-physics_Matheart/tests/test_electromagnetism.py
__module_test__ = "electromagnetism" from manim import * from manim.utils.testing.frames_comparison import frames_comparison from manim_physics.electromagnetism.electrostatics import * from manim_physics.electromagnetism.magnetostatics import * @frames_comparison def test_electric_field(scene): charge1 = Charge(-1, LEFT + DOWN) charge2 = Charge(2, RIGHT + DOWN) charge3 = Charge(-1, UP) field = ElectricField(charge1, charge2, charge3) scene.add(charge1, charge2, charge3) scene.add(field) @frames_comparison def test_magnetic_field(scene): wire = Wire(Circle(2).rotate(PI / 2, UP)) field = MagneticField(wire) scene.add(field, wire)
manim-physics_Matheart/tests/test_wave.py
__module_test__ = "waves" from manim import * from manim.utils.testing.frames_comparison import frames_comparison from manim_physics.wave import * @frames_comparison() def test_linearwave(scene): wave = LinearWave() wave.set_time(2) scene.add(wave) @frames_comparison() def test_radialwave(scene): wave = RadialWave( LEFT * 2 + DOWN * 5, # Two source of waves RIGHT * 2 + DOWN * 5, checkerboard_colors=[BLUE_D], stroke_width=0, ) wave.set_time(2) scene.add(wave) @frames_comparison def test_standingwave(scene): wave1 = StandingWave(1) wave2 = StandingWave(2) wave3 = StandingWave(3) wave4 = StandingWave(4) waves = VGroup(wave1, wave2, wave3, wave4) waves.arrange(DOWN).move_to(ORIGIN) scene.add(waves) for wave in waves: wave.start_wave() scene.wait()
manim-physics_Matheart/tests/test_pendulum.py
__module_test__ = "pendulum" from manim import * from manim.utils.testing.frames_comparison import frames_comparison from manim_physics.rigid_mechanics.pendulum import * @frames_comparison(base_scene=SpaceScene) def test_pendulum(scene: SpaceScene): pends = VGroup(*[Pendulum(i) for i in np.linspace(1, 5, 7)]) scene.add(pends) for p in pends: scene.make_rigid_body(*p.bobs) p.start_swinging() scene.wait() @frames_comparison(base_scene=SpaceScene) def test_multipendulum(scene): p = MultiPendulum(RIGHT, LEFT) scene.add(p) scene.make_rigid_body(*p.bobs) p.start_swinging() scene.add(TracedPath(p.bobs[-1].get_center, stroke_color=BLUE)) scene.wait()
manim-physics_Matheart/docs/source/changelog.rst
========= Changelog ========= **v0.3.0** ========== Breaking Changes ---------------- - Huge library refactor. - :class:`~.MagneticField` now takes a :class:`~.Wire` parameter. This allows for a 3D field. - Optimized field functions for both :class:`~.ElectricField` and :class:`~.MagneticField`. **v0.2.5** ========== Bugfixes -------- - ``VGroup`` s can be whole rigid bodies. Support for ``SVGMobject`` s **v0.2.4** ========== 2021.12.25 New Features ------------ - Hosted `official documentation <https://manim-physics.readthedocs.io/en/latest/>`_ on readthedocs. The readme might be restructured due to redundancy. - New ``lensing`` module: Mobjects including ``Lens`` and ``Ray`` - ``SpaceScene`` can now specify the gravity vector. - Fixed ``ConvertToOpenGL`` import error for ``manim v0.15.0``. Improvements ------------- - Combined ``BarMagneticField`` with ``CurrentMagneticField`` into ``MagneticField``. - Improved the updaters for ``pendulum`` module. Frame rate won't show any lagging in the pendulum rods. Bugfixes --------- - Updated deprecated parameters in the ``wave`` module. **v0.2.3** ========== 2021.07.14 Bugfixes -------- - Fix the small arrow bug in ``ElectricField`` **v0.2.2** ========== 2021.07.06 New objects ----------- - **Rigid Mechanics**: Pendulum Bugfixes -------- - Fix the ``__all__`` bug, now ``rigid_mechanics.py`` can run normally. Improvements ------------ - Rewrite README.md to improve its readability **v0.2.1** ========== 2021.07.03 New objects ----------- - **Electromagnetism**: Charge, ElectricField, Current, CurrentMagneticField, BarMagnet, and BarMagnetField - **Wave**: LinearWave, RadialWave, StandingWave Bugfixes -------- - Fix typo Improvements ------------ - Simplify rigid-mechanics **v0.2.0** ========== 2021.07.01 Breaking Changes ---------------- - Objects in the manim-physics plugin are classified into several **main branches** including rigid mechanics simulation, electromagnetism and wave.
manim-physics_Matheart/docs/source/contributing.rst
Contributing ============ Contributions are welcome! The repository owner (Matheart) might not be available, any pull requests or issues will be attended by other developers. There's three parts in a contribution: 1. The proposed addition/improvement. 2. Documentation for the new addition. 3. Tests for the addition. Nearly all contributing guidelines here are identical to `Manim's Contributing Guidelines <https://docs.manim.community/en/stable/contributing.html>`_.
manim-physics_Matheart/docs/source/reference.rst
Reference --------- .. toctree:: :maxdepth: 2 reference_index/electromagnetism reference_index/optics reference_index/rigid_mechanics reference_index/wave
manim-physics_Matheart/docs/source/index.rst
Manim Physics ------------- Welcome to the `manim-physics` official documentation! Installation ++++++++++++ ``manim-physics`` is a package on pypi, and can be directly installed using pip: .. code-block:: powershell pip install manim-physics .. warning:: Please do not directly clone the github repo! The repo is still under development and it is not a stable version, download manim-physics through pypi. Usage +++++ Include the import at the top of the .py file .. code-block:: from manim_physics import * Index +++++ .. toctree:: :maxdepth: 2 reference changelog contributing
manim-physics_Matheart/docs/source/conf.py
# Configuration file for the Sphinx documentation builder. # # This file only contains a selection of the most common options. For a full # list see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html from __future__ import annotations import os import sys import manim_physics # -- Path setup -------------------------------------------------------------- # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. sys.path.insert(0, os.path.abspath(".")) # -- Project information ----------------------------------------------------- project = "Manim Physics" copyright = "2020-2022, The Manim Physics Dev Team" author = "The Manim Physics Dev Team" # -- General configuration --------------------------------------------------- # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ "sphinx.ext.autodoc", "sphinx_copybutton", "sphinx.ext.napoleon", "sphinx.ext.autosummary", "sphinx.ext.doctest", "sphinx.ext.extlinks", "sphinx.ext.viewcode", "manim.utils.docbuild.manim_directive", "sphinxcontrib.programoutput", "myst_parser", ] # Automatically generate stub pages when using the .. autosummary directive autosummary_generate = True # generate documentation from type hints autodoc_typehints = "description" autoclass_content = "both" # controls whether functions documented by the autofunction directive # appear with their full module names add_module_names = False # Add any paths that contain templates here, relative to this directory. templates_path = ["_templates"] # Custom section headings in our documentation napoleon_custom_sections = ["Tests", ("Test", "Tests")] # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This pattern also affects html_static_path and html_extra_path. exclude_patterns: list[str] = [] # -- Options for HTML output ------------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # html_theme = "furo" # html_favicon = str(Path("_static/favicon.ico")) # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". # html_static_path = ["_static"] html_theme_options = { "source_repository": "https://github.com/Matheart/manim-physics/", "source_branch": "main", "source_directory": "docs/source/", "top_of_page_button": None, "light_css_variables": { "color-content-foreground": "#000000", "color-background-primary": "#ffffff", "color-background-border": "#ffffff", "color-sidebar-background": "#f8f9fb", "color-brand-content": "#1c00e3", "color-brand-primary": "#192bd0", "color-link": "#c93434", "color-link--hover": "#5b0000", "color-inline-code-background": "#f6f6f6;", "color-foreground-secondary": "#000", }, "dark_css_variables": { "color-content-foreground": "#ffffffd9", "color-background-primary": "#131416", "color-background-border": "#303335", "color-sidebar-background": "#1a1c1e", "color-brand-content": "#2196f3", "color-brand-primary": "#007fff", "color-link": "#51ba86", "color-link--hover": "#9cefc6", "color-inline-code-background": "#262626", "color-foreground-secondary": "#ffffffd9", }, } html_title = f"Manim Physics v{manim_physics.__version__}" # This specifies any additional css files that will override the theme's html_css_files = ["custom.css"] # external links extlinks = { "issue": ("https://github.com/Matheart/manim-physics/issues/%s", "#%s"), "pr": ("https://github.com/Matheart/manim-physics/pull/%s", "#%s"), } # opengraph settings ogp_site_name = "Manim Physics | Documentation" html_js_files = [ "responsiveSvg.js", ]
manim-physics_Matheart/docs/source/reference_index/rigid_mechanics.rst
Rigid Mechanics --------------- .. currentmodule:: manim_physics .. autosummary:: :toctree: ../reference ~rigid_mechanics.rigid_mechanics ~rigid_mechanics.pendulum
manim-physics_Matheart/docs/source/reference_index/electromagnetism.rst
Electromagnetism ================ .. currentmodule:: manim_physics .. autosummary:: :toctree: ../reference ~electromagnetism.electrostatics ~electromagnetism.magnetostatics
manim-physics_Matheart/docs/source/reference_index/optics.rst
Optics ------ .. currentmodule:: manim_physics .. autosummary:: :toctree: ../reference ~optics.lenses ~optics.rays
manim-physics_Matheart/docs/source/reference_index/wave.rst
Waves ======== .. currentmodule:: manim_physics .. autosummary:: :toctree: ../reference ~wave
manim-physics_Matheart/docs/source/_templates/autosummary/class.rst
{{ name | escape | underline}} Qualified name: ``{{ fullname | escape }}`` .. currentmodule:: {{ module }} .. autoclass:: {{ objname }} :show-inheritance: :members: {% block methods %} {%- if methods %} .. rubric:: {{ _('Methods') }} .. autosummary:: :nosignatures: {% for item in methods if item != '__init__' and item not in inherited_members %} ~{{ name }}.{{ item }} {%- endfor %} {%- endif %} {%- endblock %} {% block attributes %} {%- if attributes %} .. rubric:: {{ _('Attributes') }} .. autosummary:: {% for item in attributes %} ~{{ name }}.{{ item }} {%- endfor %} {%- endif %} {% endblock %}
manim-physics_Matheart/docs/source/_templates/autosummary/module.rst
{{ name | escape | underline }} .. currentmodule:: {{ fullname }} .. automodule:: {{ fullname }} {% block attributes %} {% if attributes %} .. rubric:: Module Attributes .. autosummary:: {% for item in attributes %} {{ item }} {%- endfor %} {% endif %} {% endblock %} {% block classes %} {% if classes %} .. rubric:: Classes .. autosummary:: :toctree: . :nosignatures: {% for class in classes %} {{ class }} {% endfor %} {% endif %} {% endblock %} {% block functions %} {% if functions %} .. rubric:: {{ _('Functions') }} {% for item in functions %} .. autofunction:: {{ item }} {%- endfor %} {% endif %} {% endblock %} {% block exceptions %} {% if exceptions %} .. rubric:: {{ _('Exceptions') }} .. autosummary:: {% for item in exceptions %} {{ item }} {%- endfor %} {% endif %} {% endblock %} {% block modules %} {% if modules %} .. rubric:: Modules .. autosummary:: :toctree: :recursive: {% for item in modules %} {{ item }} {%- endfor %} {% endif %} {% endblock %}
README.md exists but content is empty.
Downloads last month
22