GithubHelp home page GithubHelp logo

dylannalex / curvipy Goto Github PK

View Code? Open in Web Editor NEW
69.0 69.0 4.0 2.08 MB

Make math animations in a few lines of code.

Home Page: https://curvipy.readthedocs.io/en/latest/

License: MIT License

Python 100.00%
animations curves mathematics python

curvipy's Issues

Add tests

Create a tests directory for testing Curvipy classes.

Add an 'exclude' parameter to 'curvipy.Interval'

The idea is to exclude a list of values from the interval, so they won't be considered when plotting the curve.

curvipy.Interval:
    Parameters
    ----------
    start : int or float
        Real number in which the interval starts.
    end : int or float
        Real number in which the interval ends.
    samples: int
        Number of values within the interval. The more samples, the more precise the \
        curve plot is.
    exclude: list[int or float]
        List of values that will be excluded from the interval.

Example: imagine we want to plot the curve $f(x) = 1/x$ on the interval $x \in [-a, a]$. Since $f(0)$ is not defined, the current way of doing that is to create two intervals:

import curvipy


def f(x):
    return 1 / x


plotter = curvipy.Plotter()

a = 10
curve = curvipy.Function(f)
interval_one = curvipy.Interval(-a, -0.1, 100)
interval_two = curvipy.Interval(0.1, a, 100)

plotter.plot_curve(curve, interval_one)
plotter.plot_curve(curve, interval_two)
plotter.wait()

With an 'exclude' parameter on 'curvipy.Interval' class, we could accomplish the same goal with only one interval:

import curvipy


def f(x):
    return 1 / x


plotter = curvipy.Plotter()

a = 10
curve = curvipy.Function(f)
interval = curvipy.Interval(-a, a, 200, exclude=[0])

plotter.plot_curve(curve, interval)
plotter.wait()

If somebody wants to work on it, please make a comment. Implementing this is not as easy as it seems and might need modifications in other classes like curvipy.Plotter and/or curvipy.Curve.

Add axes labels

This implies adding two new attributes to 'curvipy.AxesConfiguration' class:

  • 'curvipy.AxesConfiguration.x_label'
  • 'curvipy.AxesConfiguration.y_label'

Show numbers on the x and y axes

A few aspects to keep in mind:

  • Number shown depend on 'curvipy.Plotter.x_axis_scale' and 'curvipy.Plotter.y_axis_scale'.
  • Add a new 'curvipy.Plotter' attribute to indicate the quantity of numbers to be displayed on the axes.
  • Add a method 'curvipy.ScreenFacade' to display text on screen. This method will be used by 'curvipy.Plotter' to display the numbers on the axes.

Update GIFs from docs/source/img for curvipy v1.1.0

GIFs shown on documentation (both README and docs) are from curvipy v1.0.1. To update the animations, just run the code shown above the GIF and record the screen with some third party software (e.g. ActivePresenter).

Add vector addition and subtraction operations.

Given the vectors $\vec{v}$ and $\vec{w}$, we want to compute $\vec{n} = \vec{v} + \vec{w}$ and $\vec{m} = \vec{v} - \vec{w}$ as shown below:

import curvipy

v = curvipy.Vector([10, 10])
w = curvipy.Vector([5, -5])
n = v + w
m = v - w

This is not possible on Curvipy 1.0.1. To do so, users have to calculate $\vec{n}$ and $\vec{m}$ manually:

import curvipy

v = curvipy.Vector([10, 10])
w = curvipy.Vector([5, -5])
n = curvipy.Vector([10 + 5, 10 + (-5)])
m = curvipy.Vector([10 - 5, 10 - (-5)])

Problematic return type of the `points` method

The Curve class and its subclasses use the method points to return the curve points.
Currently, the return type of the points method is list[int | float].
But the return type should be list[tuple[int | float, int | float]]

A rotation function

A function that rotates the curve by a certain $\theta$ angle. The implementation is easy, it will take $\theta$, and the curve as input, and method is just like TransformedCurve, but the matrix used will be:

$$A(\theta)=\begin{pmatrix} \cos\theta & -\sin\theta\\ \sin\theta & \cos\theta \end{pmatrix}$$

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.