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
E se Eva tinha optado pela cobra?
Facebook.

Epicicloids e Epitrochoids

Epicicloids, [;r,R >0;] e [; \omega=\frac{R+r}{r} ;]:
[; \underline{\textbf{r}}(t) = \begin{pmatrix} (R+r)\cos{t}-r \cos{\omega t}\\ (R+r)\sin{t}-r \sin{\omega t}\\ \end{pmatrix}, \quad t \in \mathbb{R} ;]
Epitrocoids, [; r,R >0, b \in \mathbb{R};]:
[; \underline{\textbf{r}}(t) = \begin{pmatrix} (R+r)\cos{t}-(r+b) \cos{\omega t}\\ (R+r)\sin{t}-(r+b) \sin{\omega t}\\ \end{pmatrix}, \quad t \in \mathbb{R} ;]
  1. Desenhe os Epicicloids para [;R=1;] e [;r=3,2,1,1/2,1/3;]
  2. Desenhe os Epitrocoids para [;R=1=;], [;r=3,2,1,1/2,1/3;] e [;b=3,2,1,1/2,1/3,0,-1/3,-1/2,-1,-2,-3;].
Em Epicycloid.py:
Python Listing: ../../../Code/Epicycloid.py.
from math import *
from Vector import *
from Curve import Curve

class Epicycloid(Curve):
    Name="Epicycloid"
    
    #Parameters
    R=1.0
    r=0.5
    
    NP=400
    
    t1=0
    t2=12.0*pi

    def __init__(self,R=1.0,r=0.0,NP=0):
        self.rR=R
        self.r=r

        self.Omega=(self.rR+self.r)/(self.r)
        
        if (NP): self.NP=NP

        return

    def R(self,t):
        return Vector([
            (self.rR+self.r)*cos(t)-self.r*cos(self.Omega*t),
            (self.rR+self.r)*sin(t)-self.r*sin(self.Omega*t),
        ])

    def PMin(self):
        maxx=self.rR+2.0*self.r
        return Vector([-maxx,-maxx])

    def PMax(self):
        maxx=self.rR+2.0*self.r
        return Vector([maxx,maxx])
Em Epicycloids.py:
Python Listing: ../../../Code/Epicycloids.py.
from Vector import *
from Epicycloid import Epicycloid


R=1.0
rss=[
    6.0,5.0,4.0,3.0,2.0,1.0,
    1.0/2.0,1.0/3.0,1.0/4.0,
    1.0/5.0,1.0/6.0
]

N=100
NP=400

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

color1=[255,0,0] #red
color2=[0,0,255] #blue

dt=1.0/(1.0*(len(rss)-1))

files=[]
ssvg=[]
n=0
t=0.0
for r in rss:
    curve=Epicycloid(R,r,NP)
    curve.Rs()
    curve.Init_Canvas()
    fname=curve.Name+"/"+("%03d" % n)+".svg"
    options={
        "stroke": 'blue',
        "style": { "stroke-width": 2, }
    }
    svg=[]
    svg=svg+curve.Curve_SVG_Polyline(options)
    curve.SVG_2_File(fname,svg)

    options={
        "stroke": "rgb("+",".join(
            curve.Colors_Convex(color1,color2,t)
        )+")",
        "style": { "stroke-width": 2, }
    }
    ssvg=ssvg+curve.Curve_SVG_Polyline(options)
    files.append(fname)
    n+=1
    t+=dt
    
curve.SVG_2_File(curve.Name+"/"+curve.Name+".svg",ssvg) 
curve.Curve_Carousel(files)
Messages:
0 secs.