SmtC: Show me the Code
Ole Peter Smith
Instituto de Matemática e Estatística
Universidade Federal de Goiás
http://www.olesmith.com.br

Atividades 2
O dia que bosta valesse ouro.
Os pobres todos nascerão sem c*.
Grafitti.
< 2.4: Hipérbolas | 2.5: Cicloids e Trocoids | 2.6: Epicloids e Epitrocoids >

Cicloids e Trochoids

Cicloids, [;a>0;]:
[; \underline{\textbf{r}}(t) = \begin{pmatrix} a(t-\sin{t})\\a(1-\cos{t}) \end{pmatrix} ;]
Trocoids, [;a>0;, b \in \mathbb{R};]:
[; \underline{\textbf{r}}(t) = \begin{pmatrix} at-(a+b)\sin{t}\\a-(a+b)\cos{t}) \end{pmatrix} ;]
  1. Desenhe os Cicloids para [;a=1,2,3,4,5;]
  2. Desenhe os Trochoids para [;a=1=;] e [;b \in [-2,2];]
Python Listing: ../../../Code/Trochoid.py.
from math import *

from Vector import *
from Curve  import Curve

class Trochoid(Curve):
    Name="Trochoid"

    #Parameters
    a=1.0
    b=0.0

    NP=400
    t1=0
    t2=8.0*pi
    
    def __init__(self,a=1.0,b=0.0,NP=0):
        self.a=a
        self.b=b
        if (NP): self.NP=NP
        
        return
    
    def R(self,t):
        return Vector([
            self.a*t-(self.a+self.b)*sin(t),
            self.a-(self.a+self.b)*cos(t)
        ])

    def PMin(self):
        return Vector([self.t1,-1.5])
    
    def PMax(self):
        return Vector([self.t2,4.0 ])
Python Listing: ../../../Code/Trochoids.py.
from Vector   import *
from Trochoid import Trochoid

a=1.0

b1=-2.0
b2=2.0

N=100
NP=400

db=1.0*(b2-b1)/( 1.0*(N-1) )

cycloid=Trochoid(a,0.0,NP)
cycloid.Rs()

palette=[
    "red","yellow","oragne","blue","green","black",
    "magenta","cyan"
]

b=b1

files=[]

ssvg=[]
for n in range(N):
    curve=Trochoid(a,b,NP)
    curve.Rs()

    curve.Init_Canvas()

    #Transfer Canvas
    cycloid.Canvas=curve.Canvas

    fname="Trochoid/"+("%03d" % n)+".svg"
    options={
        "stroke": 'blue',
        "style": {
            "stroke-width": 2,
        }
    }

    svg=[]
    svg=svg+curve.Curve_SVG_Line(options)
    
    options={
        "stroke": palette[ (n % len(palette)) ],
        "style": {
            "stroke-width": 2,
        }
    }

    ssvg=ssvg+curve.Curve_SVG_Line(options)
    
    options[ "stroke" ]='green'
    svg=svg+cycloid.Curve_SVG_Line(options)

    curve.SVG_2_File(fname,svg)
    files.append(fname)

    b+=db
curve.Curve_Carousel(files)

curve.SVG_2_File("Trochoid/Trochoids.svg",ssvg)

< 2.4: Hipérbolas | 2.5: Cicloids e Trocoids | 2.6: Epicloids e Epitrocoids >
Messages:
0 secs.