Ole Peter Smith, IME, UFG ole@mat.ufg.br EMSL '10 15/10/2010/2010 UFU, Uberlândia-MG
The Road to Knowledge? Simple: Err, and Err, and Err again But Less, and Less, and Less Piet Hein Real programmers can write assembly code in any language Larry Wall TIMTOWTDI: There is more than one Way to Do It! Larry Wall
Curiosity Inteligência: Potencial Sabedoria: Disciplina & Curiosidade Graphics Programming Math & Art Visualization - Animation The Road to Wisdom? Simple, my Friend: Err, Err and Err Again... But Less and Less and Less Programming vs. Medicine... Piet Hein
The Mathematics Geometria Analítica 2D - 3D Planos - Curvas - Superfícies Euclidian Álgebra Linear Matrizes - Transformações - AutoVetor/Valor Geometria Diferencial Cinemática Análise Numérica Ferramenta Geometria Projetiva Noneuclidian Fractais
Implementation Language: Perl, PHP, C/C++, Java,... Graphics Library: GD - Others Ex: Apache - HTML - PHP - Browser www.apache.org www.php.org - www.perl.org www.gd.org O mais Importante não é Saber de Tudo O mais Importante Saber onde Procurar! Limite da Minha Pesquisa Pessoal: Minha Própria Inteligência, Disciplina e Curiosidade
Estrutura: $image=createimageobject; $image->drawsomething; $image->imageline10,10,390,390; $image->imagearcfilled200,200,10,10; $image->writeimage; $image->close; Pixels - Coordenadas
Image Formats: PNG - GIF - JPG -... Animated GIF - MPG Resolution: X, Y = 800x600 Physical: [x min, x max ]x[y min, y max ] Canonical: [0, 1]x[0, 1] X, Y = 0, 0 é Upper Left Linear Transformation: X Y A X = A x x = A 1 X a = A x = 11 a 12 x = x min y min a 21 a 22 0 = Y, A y x max y max a 11 x + a 12 y a 21 x + a 22 y = X 0
Image A x min x max y min y max = 0 X Y 0 A = 0 X Y 0 X 1 Tarefa: Inversa de Matriz Regular det 0 - Gauss - LU Tarefa: Imagem de Aplicação Linear: for $i=0;$i<$dim;$i++ { $X[$i]=0.0; for $j=0;$j<$dim;$j++ { $X[$i]+=$A[$i][$j]*$x[$j]; } $X[i]=$sum }
Dot Product Measure: Lenths and Angles x = x 1,..., x n, y = y 1,..., y n x y = x 1 y 1 +... + x n y n = $dot=0.0; for $i=0;$i<$n;$i++ { $dot+=$x[$i]*$y[$i]; } n i=1 x i y i = x T y Length: x = x x Angle: cos a, b = a b a b
Plane Curves Equation: F x, y = 0 x Function: rx = f x Parametrization: rt = xt yt, t 1 t t 2 $dt=$t2-$t1/$n-1; for $i=0,$t=$t1;$i<$n;$i++ { array_push$ps,arrayx$t,y$t; } Building Stones: Line Segments - ArcFilled
Line Line Segment: p 1 = x 1, y 2 e p 2 = x 2, y 2. r = p 2 p 1. Versor de r = r x, r y : n = r = r y, r x Parametrization/Convex Combination: x y = x 1 y 1 + t x 2 x 1 y 2 y 1, 0 t 1 Normal: a b = ry r x Equation: ax x 1 + by y 1 = 0 ax + by = ax 1 + by 1 = c
Circle/Ellipse Center: p c = x c, y c, half-axes: a, b a = b: Circle Equation: x x c a 2 + y y c b 2 = 1 Parametrization: xt yt = x c + a cos t y c + b sin t 0 t 2π
Hiperbola Center: p c = x c, y c e halfaxes, a, b Equation: x x c a 2 y y c Parametrization: xt = yt b x c + a cosh t y c + b sinh t 2 = ±1 α t α Funções Hiperbólicas cosh t = et + e t sinh t = et e t 2 2 cosh 2 t sinh 2 t = 1
Cinematics Position: rt = xt yt Tangent & Velocity: r x t = t y vt = r t t r t = Unit Tangent & Normal: tt = 1 x t vt y t Acceleration:, nt = tt = 1 vt r t = x t y t Arc Length: st st 0 = t t 0 x t 2 + y t 2 dt 1 x t 2 + y t 2 y t x t,
Curvature Oscillating Circe: Same tangent & Accelleration ρ = [r tr t] x t 2 + y t 23 Radius of Oscillating Circe, ρ: Curvature: ρt = [r tr t] x t 2 + y t 23 κt = 1 ρt Curvature Vector & Center of Curvature Curvature: p c t = rt + ρtnt
Transformations Linear: f x = Ax, f αx + βy = αf x + βf y If det A 0: f 1 y = A 1 y An: f x = Ax + b Rotate Coordinate System: x = Dx, D 1 = D T D ortogonal: Preserves Lengths and Angles: D x D x = x x
Scaling Scaling resp. Origin, factor λ R around x-axis: x λ 0 λx = x = = Lλ x 0 1 y λ = 1: Identity, I λ = 1: Reection in y axis < Rev. Orient. λ = 0: Projection onto y axis λ > 1: Expansion 0 < λ < 1: Dilatation Bidirectional Scaling: x λx 0 λx x = x = = Lλ 0 λ y λ x, λ y x y y λx 0 0 λ y = λx 0 0 1 1 0 0 λ y
Translation & Rotation Translation, a - Não Linear: x = t + x Rotation resp. Origin, Angle θ - Linear: x cos θ sin θ = x = Dθ x, sin θ cos θ Dθ 1 = D θ = Dθ T
Projetive Geometry Camera at Origin, Looking at 0, 0, 1 Translation in non-linear... That Really Sucks! Remedy: Drawing plane is z = 1 instead of z = 0. Point in R 2 : x, y. Point in R 3 : x, y, 1. Do Something to Point Point in R 3 : x, y, z. Point in R 2, z 0: x/z, y/z. Point in Innity: z = 0: x, y.
Projetive, Translation Translation: Tt = 1 0 t x 0 1 t y 0 0 1 x y 1 = x + t x y + t y 1 Inverse: 1 0 t x 0 1 t y 0 0 1 x y 1 = x t x y t y 1 Tt 1 = T t
Projetive, Rotation Rotation: Rθ x y 1 = cos θ sin θ 0 sin θ cos θ 0 0 0 1 Rθ 1 = R θ = Rθ T Rotation, Angle θ, Resp. to p = p x, p y : 1: Translation to p: Tp 2: Rotation by new Origin: Rθ 3: Translation back: p T p = Tp 1 Apply from Right: R θ = Tp 1 RθTp Similar Matrices: B = D 1 AD Describe same Transformation in Dierent Bases x y 1
Scaling Unidirectional Scaling with Resp. to y-axis: λ 0 0 0 1 0 0 0 1 Unidirectional Scaling with Resp. to e = cos θ, sin θ: Coordinate System: e, ê cos θ sin θ Dθ = sin θ cos θ, x old = Dθx new x new = Dθ 1 x old 1: Change Coordinate System: cos θ sin θ 0 Rθ = sin θ cos θ 0 0 0 1
Scaling 2: Scale with Resp. to y-axis Lλ = λ 0 0 0 1 0 0 0 1 3: Rotate back R θ = Rθ 1 = cos θ sin θ 0 sin θ cos θ 0 0 0 1 Composition from right: Again: Similar Matrices Rθ 1 LλRθ
Animation $nimages=79; $dt=2.0*3.1415927/$nimages; system"/bin/rm Wheel*.gif"; for $t=0.0,$i=0;$i<$nimages;$i++ { $image = ImageCreate... $center=array3.0,3.0; DrawWheel$image,200,5,$center,0.2,2.0,$color,$t; imagegif$image,"wheel.$i.gif"; $t+=$dt; } //Merda! PHP nao tem suporte para GIF animado... system"/usr/bin/convert -delay 2 -loop 0 ". "Wheel.*.gif Wheel.gif";
Given: Fixed Curve X t, Y t, 0 t 1. Circle to Roll, Radius r Mark Point Initially: Point in X 0, Y 0. Roll Circle without Sliding: Cycloid: Circle on Line st = rθ Epicycloid: Circle Outside Circle Hypocycloid: Circle Inside Circle Trochoid, Epitrochoid, Hypotrochoid,... Oloid
Cycloid
Trochoid
Trochoid
Epicycloid
Hypocycloid
Oloid