Giter VIP home page Giter VIP logo

animations's Introduction

Table of Contents

  1. Installation

    1. Instructions
      1. Create an environment with Conda
      2. Activate the environment
      3. Install dependencies
    2. Summary
  2. Algorithm documentation (TODO)

    1. Integrals and the Monte Carlo Method
    2. IFS
    3. Compound Interest and calculation of yearly, monthly and daily returns
    4. Euclid's Algorithm, the Fundamental Arithmetic Theorem and the Decimal Number System
      1. Animation - group of dots
      2. Create Rounding Boxes

    (setq org-format-latex-options (plist-put org-format-latex-options :scale 3.0))

Installation

Instructions on creating, activating and download the dependencies will be given in Instructions

Prerequisites:

  • Conda
  • Manim
  • Numpy
  • Scipy

Instructions

Create an environment with Conda

Let’s create an environment, which we will call manim, but you can call it whatever you fell like.

conda create -n manim python=3.11 anaconda

Activate the environment

In a terminal (for installing the dependencies), or (later on) in your favorite editor, activate the environment.

conda activate manim
  1. Emacs

    In Emacs, you can use M-x conda-env-activate, using conda.el (repository for conda.el)

    Then, upon calling run-python, the python repl will be using conda’s environment.

    Anything you sent to it, will contain the packages you installed (like manim). So, you can import it and run the animations.

Install dependencies

After activating the environment,

conda install -c conda-forge manim numpy scipy

Summary

conda create -n manim
conda activate manim
conda install -c conda-forge manim numpy scipy

TODO Algorithm documentation (TODO)

Integrals and the Monte Carlo Method

TODO IFS

TODO Compound Interest and calculation of yearly, monthly and daily returns

TODO Euclid's Algorithm, the Fundamental Arithmetic Theorem and the Decimal Number System

\begin{equation} \begin{aligned} \forall(x,,y), \exists(t,r) , \ni , y = x*t + r \end{aligned} \end{equation}

Animation - group of dots

  1. Create n dots

    Given a number, create n dots, by using the greatest value, by one of the relative primes, which compose n.

    def create_n_dots(n, **kwargs):
        factors_map = factorint(n)
        factors = list(factors_map.keys())
        factors_values = [factor ** factors_map[factor] for factor in factors]
        if len(factors) >= 2:
            max_factor_value = int(max(factors_values))
            rest_factors = int(n / max_factor_value)
        else:
            if list(factors_map.values())[0] % 2 == 0:
                max_factor_value = int(factors[0] ** (factors_map[factors[0]] / 2))
                rest_factors = int(n / max_factor_value)
            else:
                max_factor_value = int(factors[0] ** math.ceil(factors_map[factors[0]] / 2))
                rest_factors = int(n / max_factor_value)
    
        return create_dots(max_factor_value, rest_factors, **kwargs)
    
  2. Create dots

    Given a number $p=n.m$, This function creates $n.m$ (2D-display) dots, in a VGroup.

    def create_dots(n, m, *args, **kwargs):
        color = kwargs["color"]
        all_dots = VGroup()
    
        if args:
            print(args)
            print(args[0])
            x_plus = args[0]
            j = math.floor(x_plus / n)
            remainder = x_plus % n
            all_dots = (
                create_dots(n, m, color=color)
                .add(create_dots(n, j, color=GREEN).shift([n + 1, 0, 0]))
                .add(create_dots(1, remainder, color=YELLOW_A).shift([m + j, 0, 0]))
                .shift([-(m + m / j), 0, 0])
            )
    
            return all_dots
    
        else:
            for i in range(n):
                dots = VGroup()
                for j in range(m):
                    dots.add(Dot([j, i, 0], color=color))
                    all_dots.add(dots)
    
            return all_dots
    

Create Rounding Boxes

  1. Create rounding box around vgroups

    def create_rouding_boxes(vgroups, *args, **kwargs):
        """VGroups"""
        color = kwargs["config"]["color"]
        text = kwargs["config"]["text"]
    
        if kwargs["config"].keys().__contains__("buff"):
            buff = kwargs["config"]["buff"]
        else:
            buff = 0.1
    
        boxes = VGroup()
        if args:
            n = len(list(vgroups))
            m = len(list(vgroups[0]))
            new_text = Text(f"N = {n}*{m}", font_size=24).to_edge(UP).set_color(YELLOW)
            for j in range(m):
                box = VGroup()
                for i in range(n):
                    box.add(vgroups[i][j])
                    boxes.add(SurroundingRectangle(box, buff=buff, color=color))
            return boxes, new_text
    
        else:
            n = len(list(vgroups))
            m = len(list(vgroups[0]))
            new_text = Text(f"N = {m}*{n}", font_size=24).to_edge(UP).set_color(YELLOW)
            for vgroup in vgroups:
                boxes.add(SurroundingRectangle(vgroup, buff=buff, color=color))
            return boxes, new_text
    
  2. Further decompose the rounding boxes

    def create_rouding_boxes_decomposition(vgroups, *args, **kwargs):
        color = kwargs["config"]["color"]
        text = kwargs["config"]["text"]
        boxes = VGroup()
        n = len(list(vgroups))
        m = len(list(vgroups[0]))
    
        factorsm = factorint(m)
        factor1 = list(factorsm.keys())[0]
        p = int(m / factor1)
    
        new_text = (
            Text(f"N = ({factor1}*{p})*{n}", font_size=24).to_edge(UP).set_color(YELLOW)
        )
    
        for i in range(n):
            box = VGroup()
            for j in range(m):
                if (j + 1) % p == 0:
                    box.add(vgroups[i][j])
                    boxes.add(SurroundingRectangle(box, buff=0.1, color=color))
                    box = VGroup()
                else:
                    box.add(vgroups[i][j])
        return boxes, new_text
    

animations's People

Contributors

buddhilw avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.