Git Product home page Git Product logo

roller-coaster-loops's Introduction

Roller coaster loops

Applying calculus to real-world physics to compute the shape of a roller coaster loop.

Requirements

This program should work on Python 2.7.x and 3.x.

Install

pip install -r requirements.txt

Usage

python main.py [C1, C2, ...]

Example

python main.py 2 3 4 5

Derivation

The derivation of equations is based on [1]. Scipy's default non-linear ODE solver is used instead of Euler's method.

The loop shape is computed so that the centripetal force a_c stays constant along the track segment:

a_c = C * g  # (1)

where C is a non-dimensional parameter.

We then derive the expression of the radius r along the track section.

The centripetal acceleration is commonly express as:

a_c = v ** 2 / r  # (2)

Using (1) and (2) we get:

r = v ** 2 / (G * g)  # (3)

But the conservation of energy gives us:

v ** 2 = v_0 ** 2 - 2 * g * y

And so:

r = 1 / C * (v_0 ** 2 / g - 2 * y)

The relationship between r the curvilinear abscissa s is:

Θ/s = 1/r

Besides, s can be related to the abscissa x and the height y of a given point of the track section using:

x/s = cos(Θ)
∂y/s = sin(Θ)

This allows us to write the final system of non-linear ODEs:

Θ/s = C / (v_0 ** 2 / g - 2 * y)
∂x/s = cos(Θ)
∂y/s = sin(Θ)

This system can be rewritten as

dZ/ds = f(s, Z)

where Z = (Θ x y) and:

f(s, Z) = (C / (v_0 ** 2 / g - 2 * Z[2]), cos(Z[0]), sin(Z[1]))

We use this expression to integrate the system of ODEs using scipy.integrate.ode. The final results are dislayed using matplotlib.

Future work

  • Improve the CLI experience (hint: use Click).
  • Plot G against s: G = v ** 2 / (r * g) + cos(Θ).
  • Add other scenarios, e.g. circular loop, triangular/trapezoid centripetal accelaration, etc.

Bibliography

[1]: Art of Engineering, The Real Physics Of A Roller Coaster, published 2019-05-09.

roller-coaster-loops's People

Contributors

florimondmanca avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

zudiie

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.