itisrazza / conic-sections

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

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

About

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

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

License:MIT License


Languages

Language:JavaScript 76.5%Language:CSS 13.3%Language:HTML 10.3%