Giter Club home page Giter Club logo

wankeleng's Introduction

WankelEng

This is a SageMath script that draws epitrochoids and their inner envelope. This was written to better understand the inner geometry of Wankel Engines.

Raw:

Here is the raw text, for those not working in a Jupyter notebook:

n = 2

m = 0.17

t = var('t')

plope = ((1 + m) * cos(t) - m * cos((n + 1) * t), (1 + m) * sin(t) - m * sin((n + 1) * t))

epitrochoid = parametric_plot(plope, (t, -pi, pi), aspect_ratio=1)

show(epitrochoid)

a = var('a')

ite = 7 * (n + 1)
gener = []
for i in xrange(ite):
    rot = i * 2 * pi / ite
    gener.append((cos(rot) * plope[0] - sin(rot) * plope[1] + m * cos(n * -rot) , sin(rot) * plope[0] + cos(rot) * plope[1] + m * sin(n * -rot)))

rays = []

for i in xrange(n + 1):
    rays.append(parametric_plot(((1 + m) * t * cos(i * 2 * pi / (n + 1)), (1 + m) * t * sin(i * 2 * pi / (n + 1))), (t, 0, 1), aspect_ratio=1, color='red'))

show(sum(parametric_plot(gener[i], (t, -pi, pi), aspect_ratio=1) for i in xrange(len(gener))) + sum(rays))

# I should really figure out how to do this without all the sorting.
@parallel('multiprocessing')
def rotor(j):
    choices = []
    # This could be done in parallel as well, it doesn't depend on the order of the loop.
    for i in xrange(ite):
        rot = j + i * 2 * pi / ite
        choices.append( sqrt((gener[i][0].substitute(t == rot))^2 + (gener[i][1].substitute(t == rot))^2) )
    return sorted(choices)[0]

protor = polar_plot(rotor, (t, -pi, pi), aspect_ratio=1)

show(protor)

show('Done!')

wankeleng's People

Contributors

wulfsta avatar

Watchers

 avatar  avatar

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.