Curvipy - The Python package for visualizing curves and linear transformations in a super simple way

Overview

curvipy ๐Ÿ“

licence

The Python package for visualizing curves and linear transformations in a super simple way.

โœ๏ธ Installation

Install curvipy package with pip:

$ pip install curvipy

or clone the repository:

$ git clone https://github.com/dylannalex/curvipy.git

โœ๏ธ Basic usage

This is a simple use guide. You can see all curvipy functionalities at curvipy documentation.

๐Ÿ“Œ Drawing curves

To start drawing curves you need to create a GraphingCalculator object:

from curvipy import GraphingCalculator

graphing_calculator = GraphingCalculator()

curvipy let you draw parametrized curves and mathematical functions. Lets create and draw the square root of x function for this example:

def square_root(x):
    return x ** (1 / 2)

graphing_calculator.draw(square_root, (0, 25))  # We want to draw the function from x = 0 to x = 25

You can also accomplish the same result by defining the square root of x as a parameterized function:

def square_root(t):
    return t, t ** (1 / 2)

graphing_calculator.draw(square_root, (0, 25))  # We want to draw the curve from t = 0 to t = 25

๐Ÿ“Œ Linear transformations

curvipy provides a curves module which contains functions for modifying curves with linear transformations.

from curvipy import curves

๐Ÿ“ curves.transform_curve()

This function let you apply a linear transformation (specified as a matrix) to a parametrized curve. curves.transform_curve() returns the transformed curve.

Parameters:

  • curve: parametrized curve
  • matrix: linear transformation's matrix

The matrix is a tuple of tuples (or list of lists) which has the same structure as numpy arrays. A matrix
[ a b ]
[ c d ]
should be defined as:

matrix = ((a,b), (c,d))

Example:

matrix = ((1, 0), (0, -2))
graphing_calculator.draw(curves.transform_curve(square_root, matrix), (0, 25))

๐Ÿ“ curves.rotate_curve()

Rotates a curve anticlockwise by the given angle.

Parameters:

  • curve: parametrized curve
  • angle: angle in radians
    Example:
angle = pi / 4  # 90 degrees
graphing_calculator.draw(curves.rotate_curve(square_root, angle), (0, 25))

๐Ÿ“ curves.scale_curve()

Scales the given curve by the given scalar.

Parameters:

  • curve: parametrized curve
  • scalar: scalar for scaling the curve
    Example:
scalar = 2  # The function is going to be twice as bigger
graphing_calculator.draw(curves.scale_curve(square_root, 2), (0, 25))
Comments
  • Update Latex expressions

    Update Latex expressions

    Some changes might feel unnecessary, but I felt like it would be better to have those changes. Like the more conventional font for real number set or the extra line of explanation for linear transformation.

    opened by ritamsaha00 8
  • v1.1.0

    v1.1.0

    • Updated plotter:
      • 'curvipy.Plotter' now draws axes ticks and arrows (to indicate the axis direction).
      • Removed 'interval: curvipy.Interval' parameter of 'curvipy.Plotter.plot_curve()' and 'curvipy.Plotter.plot_animated_curve()' methods.
      • 'curvipy.Plotter.plot_vector()' can now display vector's components.
      • Created 'curvipy.PlottingConfiguration' and 'curvipy.AxesConfiguration'
        • Updated 'curvipy.Plotter' builder parameters to 'curvipy.Plotter(window_title: str = "Curvipy", background_color: str = "#FFFFFF", plotting_config: PlottingConfiguration, axes_config: AxesConfiguration)'.
        • Now 'x_axis_scale' and 'y_axis_scale' (defined at curvipy.AxesConfiguration') can take any real value (negative or positive) and default to one.
    • Updated vector:
      • Added vector, addition, subtraction, scaling and equality.
      • Created 'curvipy.Vector.place()' method which moves the vector to a specified set of coordinates.
    • Updated curves:
      • Removed 'interval: curvipy.Interval' parameter of 'curvipy.Curve.points()' method.
      • Added 'interval: curvipy.Interval' parameter to 'curvipy.Function' and 'curvipy.ParametricFunction' builder.
    • Updated documentation.
    opened by dylannalex 0
  • Show numbers on the x and y axes

    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.
    enhancement 
    opened by dylannalex 0
  • Add vector addition and subtraction operations.

    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)])
    
    enhancement 
    opened by dylannalex 0
  • Add an 'exclude' parameter to 'curvipy.Interval'

    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.

    enhancement wontfix 
    opened by dylannalex 0
  • 1.0.1

    1.0.1

    This update brings a structure improvement and better documentation. Curvipy 1.0.0 scripts are completely compatible with this new version:

    • Made modules private. Now importing curvipy will only import its classes.
    • Created 'curvipy._screen' module. This module contains the 'ScreenFacade' class which encapsulates the turtle package functionalities.
    • Updated documentation.
    opened by dylannalex 0
  • Bump to 1.0.0

    Bump to 1.0.0

    • Added 'curvipy.curve' module. This module contains the classes:
      • 'Curve': base class for all two-dimensional curves.
      • 'Function': unction that given a real number returns another real number.
      • 'ParametricFunction': function that given a real number returns a 2-dimensional vector.
      • 'TransformedCurve': applies a linear transformation to the given curve.
    • Added 'curvipy.interval' module. This module contains the class 'Interval', which is the interval in which a curve will be plotted.
    • Added 'curvipy.vector' module. This module contains the class 'Vector', which is a two-dimensional vector.
    • Updated 'curvipy.graphing_calculator' module (now named 'curvipy.plotter'):
      • Renamed 'curvipy.graphing_calculator' to 'curvipy.plotter' and its class 'GraphingCalculator' to 'Plotter'.
      • Replaced methods 'draw_vector', 'draw_curve' and 'draw_animated_curve' with 'plot_vector', 'plot_curve' and 'plot_animated_curve' respectively.
    • Deleted 'curvipy.lintrans' module. Linear transformations can now be defined with 'curvipy.TransformedCurve' class.
    • Updated README and docs.
    • Deleted 'examples' folder since README and docs now contains a Usage Example section.
    opened by dylannalex 0
  • Update GIFs from docs/source/img for curvipy v1.1.0

    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).

    documentation good first issue 
    opened by dylannalex 0
  • A rotation function

    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}$$

    enhancement good first issue 
    opened by ritamsaha00 2
Releases(1.1.0)
  • 1.1.0(Dec 28, 2022)

    • Updated plotter:
      • 'curvipy.Plotter' now draws axes ticks and arrows (to indicate the axis direction).
      • Removed 'interval: curvipy.Interval' parameter of 'curvipy.Plotter.plot_curve()' and 'curvipy.Plotter.plot_animated_curve()' methods.
      • 'curvipy.Plotter.plot_vector()' can now display vector's components.
      • Created 'curvipy.PlottingConfiguration' and 'curvipy.AxesConfiguration'
        • Updated 'curvipy.Plotter' builder parameters to 'curvipy.Plotter(window_title: str = "Curvipy", background_color: str = "#FFFFFF", plotting_config: PlottingConfiguration, axes_config: AxesConfiguration)'.
        • Now 'x_axis_scale' and 'y_axis_scale' (defined at curvipy.AxesConfiguration') can take any real value (negative or positive) and default to one.
    • Updated vector:
      • Added vector, addition, subtraction, scaling and equality.
      • Created 'curvipy.Vector.place()' method which moves the vector to a specified set of coordinates.
    • Updated curves:
      • Removed 'interval: curvipy.Interval' parameter of 'curvipy.Curve.points()' method.
      • Added 'interval: curvipy.Interval' parameter to 'curvipy.Function' and 'curvipy.ParametricFunction' builder.
    • Updated documentation.
    Source code(tar.gz)
    Source code(zip)
  • 1.0.1(Nov 28, 2022)

    This update brings a structure improvement and better documentation. Curvipy 1.0.0 scripts are completely compatible with this new version:

    • Made modules private. Now importing curvipy will only import its classes.
    • Created 'curvipy._screen' module. This module contains the 'ScreenFacade' class which encapsulates the turtle package functionalities.
    • Updated documentation.
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0(Oct 22, 2022)

    • Added 'curvipy.curve' module. This module contains the classes:
      • 'Curve': base class for all two-dimensional curves.
      • 'Function': unction that given a real number returns another real number.
      • 'ParametricFunction': function that given a real number returns a 2-dimensional vector.
      • 'TransformedCurve': applies a linear transformation to the given curve.
    • Added 'curvipy.interval' module. This module contains the class 'Interval', which is the interval in which a curve will be plotted.
    • Added 'curvipy.vector' module. This module contains the class 'Vector', which is a two-dimensional vector.
    • Updated 'curvipy.graphing_calculator' module (now named 'curvipy.plotter'):
      • Renamed 'curvipy.graphing_calculator' to 'curvipy.plotter' and its class 'GraphingCalculator' to 'Plotter'.
      • Replaced methods 'draw_vector', 'draw_curve' and 'draw_animated_curve' with 'plot_vector', 'plot_curve' and 'plot_animated_curve' respectively.
    • Deleted 'curvipy.lintrans' module. Linear transformations can now be defined with 'curvipy.TransformedCurve' class.
    • Updated README and docs.
    • Deleted 'examples' folder since README and docs now contains a Usage Example section.
    Source code(tar.gz)
    Source code(zip)
Owner
Dylan Tintenfich
:books: Systems engineering student at Universidad Tecnolรณgica Nacional Mendoza.
Dylan Tintenfich
Python toolkit for defining+simulating+visualizing+analyzing attractors, dynamical systems, iterated function systems, roulette curves, and more

Attractors A small module that provides functions and classes for very efficient simulation and rendering of iterated function systems; dynamical syst

null 1 Aug 4, 2021
eoplatform is a Python package that aims to simplify Remote Sensing Earth Observation by providing actionable information on a wide swath of RS platforms and provide a simple API for downloading and visualizing RS imagery

An Earth Observation Platform Earth Observation made easy. Report Bug | Request Feature About eoplatform is a Python package that aims to simplify Rem

Matthew Tralka 4 Aug 11, 2022
A program that analyzes data from inertia measurement units installed in aircraft and generates g-exceedance curves.

A program that analyzes data from inertia measurement units installed in aircraft and generates g-exceedance curves.

Pooya 1 Dec 2, 2021
The Timescale NFT Starter Kit is a step-by-step guide to get up and running with collecting, storing, analyzing and visualizing NFT data from OpenSea, using PostgreSQL and TimescaleDB.

Timescale NFT Starter Kit The Timescale NFT Starter Kit is a step-by-step guide to get up and running with collecting, storing, analyzing and visualiz

Timescale 102 Dec 24, 2022
Visualizing weather changes across the world using third party APIs and Python.

WEATHER FORECASTING ACROSS THE WORLD Overview Python scripts were created to visualize the weather for over 500 cities across the world at varying di

G Johnson 0 Jun 12, 2021
Leyna's Visualizing Data With Python

Leyna's Visualizing Data Below is information on the number of bilingual students in three school districts in Massachusetts. You will also find infor

null 11 Oct 28, 2021
A python-generated website for visualizing the novel coronavirus (COVID-19) data for Greece.

COVID-19-Greece A python-generated website for visualizing the novel coronavirus (COVID-19) data for Greece. Data sources Data provided by Johns Hopki

Isabelle Viktoria Maciohsek 23 Jan 3, 2023
Tools for calculating and visualizing Elo-like ratings of MLB teams using Retosheet data

Overview This project uses historical baseball games data to calculate an Elo-like rating for MLB teams based on regular season match ups. The Elo rat

Lukas Owens 0 Aug 25, 2021
Collection of data visualizing projects through Tableau, Data Wrapper, and Power BI

Data-Visualization-Projects Collection of data visualizing projects through Tableau, Data Wrapper, and Power BI Indigenous-Brands-Social-Movements Pyt

Jinwoo(Roy) Yoon 1 Feb 5, 2022
HM02: Visualizing Interesting Datasets

HM02: Visualizing Interesting Datasets This is a homework assignment for CSCI 40 class at Claremont McKenna College. Go to the project page to learn m

Qiaoling Chen 11 Oct 26, 2021
Keir&'s Visualizing Data on Life Expectancy

Keir's Visualizing Data on Life Expectancy Below is information on life expectancy in the United States from 1900-2017. You will also find information

null 9 Jun 6, 2022
HW 2: Visualizing interesting datasets

HW 2: Visualizing interesting datasets Check out the project instructions here! Mean Earnings per Hour for Males and Females My first graph uses data

null 7 Oct 27, 2021
A command line tool for visualizing CSV/spreadsheet-like data

PerfPlotter Read data from CSV files using pandas and generate interactive plots using bokeh, which can then be embedded into HTML pages and served by

Gino Mempin 0 Jun 25, 2022
Generate SVG (dark/light) images visualizing (private/public) GitHub repo statistics for profile/website.

Generate daily updated visualizations of GitHub user and repository statistics from the GitHub API using GitHub Actions for any combination of private and public repositories, whether owned or contributed to - no server required.

Adam Ross 2 Dec 16, 2022
Backend app for visualizing CANedge log files in Grafana (directly from local disk or S3)

CANedge Grafana Backend - Visualize CAN/LIN Data in Dashboards This project enables easy dashboard visualization of log files from the CANedge CAN/LIN

null 13 Dec 15, 2022
This is a super simple visualization toolbox (script) for transformer attention visualization โœŒ

Trans_attention_vis This is a super simple visualization toolbox (script) for transformer attention visualization โœŒ 1. How to prepare your attention m

Mingyu Wang 3 Jul 9, 2022
This project is an Algorithm Visualizer where a user can visualize algorithms like Bubble Sort, Merge Sort, Quick Sort, Selection Sort, Linear Search and Binary Search.

Algo_Visualizer This project is an Algorithm Visualizer where a user can visualize common algorithms like "Bubble Sort", "Merge Sort", "Quick Sort", "

Rahul 4 Feb 7, 2022
Visualizations of linear algebra algorithms for people who want a deep understanding

Visualising algorithms on symmetric matrices Examples QR algorithm and LR algorithm Here, we have a GIF animation of an interactive visualisation of t

ogogmad 3 May 5, 2022
Voilร , install macOS on ANY Computer! This is really and magic easiest way!

OSX-PROXMOX - Run macOS on ANY Computer - AMD & Intel Install Proxmox VE v7.02 - Next, Next & Finish (NNF). Open Proxmox Web Console -> Datacenter > N

Gabriel Luchina 654 Jan 9, 2023