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
Uma sociedade sera - sempre - avaliado
Pelo jeito que trata seus mais fracos.
Mahatma
< 2.2: Elipses | 2.3: Parabolas | 2.4: Hipérbolas >

Parabolas: Variando o Coeficiente Linear, [;b;]

Considere a Parabola:
[; \underline{\textbf{r}}(t)= \begin{pmatrix}t\\at^2+bt+c\end{pmatrix}, \quad t \in \mathbb{R} ;]
Seu Vertex é:
[; \underline{\textbf{p}}_c = \begin{pmatrix} x_c\\y_c \end{pmatrix} = \begin{pmatrix} -\frac{b}{2a}\\-\frac{b^2-4ac}{4a} \end{pmatrix} ;]
Observe que:
[; y_c=-a x_c^2+c, ;]
independentemente do [;b;]; isto é: se variamos o [;b;], o vertex da parabola se move numa parabola 'oposta'. Gere uma sequencia de parabolas, demonstrando esse fato. Output: Os arquivos Parabola/NNN.svg.
Python Listing: ../../../Code/Parabola.py.
from Vector import *
from Curve  import Curve

class Parabola(Curve):

    #Parameters
    a=1.0
    b=0.0
    c=0.0

    NP=100
    t1=-2.0
    t2=2.0
    
    def __init__(self,a=1.0,b=0.0,c=0.0,NP=0):
        self.a=a
        self.b=b
        self.c=c
        if (NP): self.NP=NP
        
        return
    
    def R(self,t):
        return Vector([
            t,
            self.a*t**2.0+self.b*t+self.c
        ])

    def PMin(self):
        return Vector([self.t1,-1.0])
    
    def PMax(self):
        return Vector([self.t2,self.t2**2.0 ])
    
    def Discriminant(self):
        return self.b**2.0-4.0*self.a*self.c
    
    def Vertex(self):
        return Vector([
            -self.b/(2.0*self.a),
            -self.Discriminant()/(4.0*self.a)
        ])
Python Listing: ../../../Code/Parabolas.py.
from Vector   import *
from Parabola import Parabola

a=1.0
c=0.0

b1=-2.0
b2=2.0

N=100
NP=100

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

parabola=Parabola(-a,0.0,c,NP)
parabola.Rs()

b=b1
for n in range(N):
    curve=Parabola(a,b,c,NP)
    curve.Rs()

    curve.Init_Canvas()

    #Transfer Canvas
    parabola.Canvas=curve.Canvas

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

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

    vertex=curve.Vertex()
    vertexx=curve.Canvas.Point_2_Pixels(vertex)
    options[ "stroke" ]='red'
    svg=svg+[ curve.SVG_Point(vertexx,options) ]

    curve.SVG_2_File(fname,svg)
    
    b+=db
< 2.2: Elipses | 2.3: Parabolas | 2.4: Hipérbolas >
Messages:
0 secs.