Giter Site home page Giter Site logo

itisrazza / conic-sections Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 1.0 18 KB

⭕↗️ A quick conic section plotter for absolutely no reason.

Home Page: https://itisrazza.github.io/conic-sections/

License: MIT License

HTML 10.28% JavaScript 76.46% CSS 13.25%
web-app javascript math maths conic-section ncea-assessment

conic-sections's Introduction

Conic Sections Plotter

What is this?

Short story: I was bored in Maths, I started writing this plotter thingie to better understand these things.

It's not perfect. It's just a learning tool for me and anyone else who wants to look at this mess of code. It was done in only a few maths classes.

How to use

Edit formulas by editing the characters marked in a reddish-yellowish background colour. If you don't have anything, the variable name will be shown instead.

You can also choose between formulas by selecting the tabs above.

Known Issues/Feature Wishlist

  • Graph doesn't change on input
  • Additional information on the graph

Design

I've decided to keep the equations seperate from the code (as in kept the in their own objects rather than intertwine them).

They are stored in the modes objects and called up when needed.

They all have their title, the equation visiable and editable by the user, a function which calculates y, whether it needs to be dualSided since Math.sqrt() only returns the positive result, required parameters and an unused properties object.

line: {
    title: "Line",
    equation: "y = $mx + $c",
    y: function(x)
    {
        var m = eval(equVars["m"])
        var c = eval(equVars["c"])

        // y = mx + c
        return (m * x) + c
    },
    dualSided: false,
    parameters: [ "m", "c" ],
    properties: { ... },  // Unused
}

Conic Sections

Straight Line

Equation: y = mx + c

return (m * x) + c

Circle

Equation: r^2 = (x - h)^2 + (y - k)^2

Rearranged into: \sqrt{r^2 - (x-h)^2} + k

return Math.sqrt(Math.pow(r, 2) - Math.pow(x - h, 2)) + k

Ellipse

Equation: 1 = \frac{(x-h)^2}{a^2}+\frac{(y-k)^2}{b^2}

Rearranged into: \sqrt{b^2 \left(1 - \frac{(x-h)^2}{a^2}\right)} + k

return Math.sqrt(Math.pow(b, 2) * (1 - (Math.pow(x - h, 2) / Math.pow(a, 2)))) + k

Parabola (Horizontal)

Equation: (y-k)^2 = 4a(x-h)

Rearranged into: \sqrt{4a(x-h)} + k

return Math.sqrt(4 * a * (x - h)) + k

Parabola (Vertical)

Equation: y - k = 4a(x - h)^2

Rearranged into: 4a(x-h^2) + k

return 4 * a * Math.pow(x - h, 2) + k

Hyperbola

Equation: 1 = \frac{(x-h)^2}{a^2} - \frac{(y-k)^2}{b^2}

Rearranged into: \sqrt{ b^2\left(\frac{ (x - k)^2 }{a^2} \right) - 1} + k

return Math.sqrt(Math.pow(b, 2) * ((Math.pow(x - h, 2) / Math.pow(a, 2))) - 1) + k

conic-sections's People

Contributors

itisrazza avatar

Watchers

 avatar

Forkers

rafitanzim

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.