Curvas no TikZ Neste t´opico opico falaremos sobre os diversos tipos de curvas feitos pelo TikZ, sendo eles os operadores: to, bend, smooth e Bezier. Nota: Use o KtikZ para fazer seus testes, por oferecer um preview em tempo real. real . Para isso, basta digitar \begin{tikzpicture} e \end{tikzpicture} e come¸car car seu desenho.
Rounded corners Antes de iniciarmos nosso tutorial sobre curvas vejamos uma op¸c˜ ao ao muito util: u ´ til: rounded corners. Esta op¸c˜ c˜ao ao permite p ermite que os cantos da figura sejam arredondados a partir de um valor num´erico. erico.
Figura 1: Exemplo do uso de rounded corners. \ begin { t i k z p i c t u r e } \ d ra ra w ( 0 ,0 ,0 ) - - + +( +( 5 ,0 , 0 ) - - + +( +( - 2 ,2 , 2 ) - - + +( +( - 3 ,0 , 0 ) - - c yc y c le le ; \ d r aw aw [ r o u nd nd e d c o rn rn e rs r s ] ( 6 ,0 , 0 ) - - + +( + ( 5 , 0) 0 ) - - + + ( - 2 , 2) 2) - - + +( +( - 3 , 0) 0 ) - - c y cl cl e ; \ d r aw aw [ r o u nd nd e d c o rn rn e rs rs = 5 m m ] ( 1 2 , 0 ) - - + +( + ( 5 , 0) 0 ) - - + +( + ( - 2 , 2) 2 ) - - + +( +( - 3 , 0) 0 ) - - c y cl cl e ; \ en d { t i k z p i c t u r e }
Figura 2: rounded corners em trˆes es raios diferentes. \ begin { t i k z p i c t u r e } \ d r aw aw ( 0 , 0) 0) r e ct c t a ng n g l e + + (2 (2 , 2 ) ; \ d r a w [ r o u n de de d c o r n er er s ] ( 3 , 0 ) r e c t a n g l e + + ( 2 , 2 ) ; \ d r a w [ r o u n de de d c o r n er er s = 1 c m ] ( 6 , 0 ) r e c t a ng ng l e + + (2 (2 , 2 ) ; \ en d { t i k z p i c t u r e }
R´egis
2011
http://latexbr.blogspot.com/
1
\begin{tikzpicture} \draw \draw (5,-4) (5,-4) -- (5,4); (5,4); \draw[roun \draw[rounded ded corners=5 corners=5mm] mm] (5,-4) (5,-4) -- (4,-4) (4,-4) -(4,4) (4,4) -- (5,4); (5,4); \draw[roun \draw[rounded ded corners=1 corners=1cm] cm] (4,-3) (4,-3) -- (1,-3) (1,-3) -(1,-1) (1,-1) -- (-1,-1 (-1,-1) ) -- (-1,1) (-1,1) -- (1,1) (1,1) -- (1,3) (1,3) -- (4,3); (4,3); \draw[roun \draw[rounded ded corners=1 corners=1cm] cm] (4,-1) (4,-1) -- (2,-1) (2,-1) -(2,1) (2,1) -- (4,1); (4,1); \draw[roun \draw[rounded ded corners=1 corners=1cm] cm] (5,-3) (5,-3) -- (7,-3) (7,-3) -(7,-1) (7,-1) -- (5,-1); (5,-1); \draw[roun \draw[rounded ded corners=1 corners=1cm] cm] (5,1) -- (7,1) -- (7,3) -- (5,3); (5,3); \draw (0,0) circle (.5); (.5); \draw (6,-2) circle (.5); \draw (6,2) circle (.5); (.5); %linhas %linhas guia \draw[red, \draw[red,dashe dashed] d] (0,-1.5) (0,-1.5) -- ++(0,3) ++(0,3) (-1.5,0) (-1.5,0) -++(3,0); \draw[red, \draw[red,dashe dashed] d] (6,-3.5) (6,-3.5) -- ++(0,3) ++(0,3) (4.5,-2) (4.5,-2) -++(3,0); \draw[red, \draw[red,dashe dashed] d] (6,0.5) (6,0.5) -- ++(0,3) ++(0,3) (4.5,2) (4.5,2) -++(3,0); %cotas \draw[<->, \draw[<->,red,r red,rotate otate=45] =45] (-.5,0) (-.5,0) -- ++(1,0) ++(1,0) node[right] {$1\,cm$}; \draw[|<-> \draw[|<->|,red |,red] ] (-2,-1) (-2,-1) -node[rotate=90,above] node[rotate=90,abo ve] {$2\,cm$} (-2,1); \draw[red, \draw[red,dashe dashed] d] (-2,-1) (-2,-1) -- (-.5,-1); (-.5,-1); \draw[red, \draw[red,dashe dashed] d] (-2,1) (-2,1) -- (-.5,1); (-.5,1); \draw[|<-> \draw[|<->|,red |,red] ] (7.5,-2) (7.5,-2) -node[rotate=90,above] node[rotate=90,abo ve] {$4\,cm$} (7.5,2); \draw[|<-> \draw[|<->|,red |,red] ] (9,-4) (9,-4) -node[rotate=90,above] node[rotate=90,abo ve] {$8\,cm$} (9,4); \draw[red, \draw[red,dashe dashed] d] (5.5,-4) (5.5,-4) -- (9,-4); (9,-4); \draw[red, \draw[red,dashe dashed] d] (5.5,4) (5.5,4) -- (9,4); (9,4); \end{tikzpicture}
R´egis
2011
http://latexbr.blogspot.com/
2
To O operador To ´e usado para adicionar adicionar um caminho caminho da coordenada coordenada anterior anterior para a coordenada coordenada (A) to (B), uma linha ´ seguinte. Quando vocˆe escreve escr eve (A) e adicionada de A para B, exatamente exatamente como se vocˆe tivesse escrito (A)--(B). to[out=90,in= 0,in=180] 180] (B) uma curva ´e adicionada ao caminho, No entanto, se vocˆe escrever (A) to[out=9 saindo do ponto A com um ˆangulo angulo de 90o e chegando no ponto B com um ˆangulo de 180o (levando em considera¸c˜ cao a˜ o que o ˆangulo angulo 0 inicia-se do lado direito de um ponto fixo e percorre no sentido anti´ (0,0) to[out=90 to[out=90,in= ,in=180] 180] (2,3) (2,3) . Os pontos A e B s˜ hor´ ario). ario). E claro que podemos digitar (0,0) ao ao pontos nomeados que s˜ao ao usados a partir do comando \coordinate. Na terceira figura temos um exemplo saindo do ponto A a 45 o e chegando em B a 135 o . 180
135
◦
B
B
90 A
A
◦
B
◦
45
◦
A
Figura 3: Exemplos do operador to. Veja o c´odigo: odigo: \ begin { t i k z p i c t u r e } \tikzset{>=latex} \ t i k z s t y l e { p o n t o } = [fill [ fill = b l u e , c i r c l e ,scale , scale =.25] \ c o o r d i n at at e [ p o n to to , l a b e l = l e ft ft : A ] ( A ) a t ( 0 , 0 ) ; \ c o o r d i n at at e [ p o n to to , l a b e l = l e ft ft : B ] ( B ) a t ( 2 , 3 ) ; \ c o o r d i n at at e [ p o n to to , l a b e l = l e ft ft : A ] ( C ) a t ( 3 , 0 ) ; \ c o o r d i n at at e [ p o n to to , l a b e l = b e l ow ow : B ] ( D ) a t ( 5 , 3 ) ; \ c o o r d i n at at e [ p o n to to , l a b e l = l e ft ft : A ] ( E ) a t ( 6 , 0 ) ; \ c o o r d i n at at e [ p o n to to , l a b e l = b e l ow ow : B ] ( F ) a t ( 8 , 3 ) ; % to \ d ra ra w ( A ) t o ( B ); ); \ d r aw aw [ - > ] ( C ) t o [ ou ou t = 90 90 , i n = 1 80 80 ] ( D ) ; \ d r aw aw [ - > ] ( E ) t o [ ou ou t = 45 45 , i n = 1 35 35 ] ( F ) ; \ en d { t i k z p i c t u r e }
R´egis
2011
http://latexbr.blogspot.com/
3
Veja a seguir um desenho um pouco mais elaborado: G
F
H
J
E I
A
D
B
C
K
Figura 4: Mais um exemplo do operador to. E o c´odigo: odigo: \ begin { t i k z p i c t u r e } \ t i k z s t y l e { p o n t o } = [fill [ fill = b l u e , c i r c l e ,scale , scale =.25] \ c o o r d i n at at e [ p o n to to , l a b e l = l e ft ft : A ] ( A ) a t ( 0 , 1 ) ; \ c o o r d i n at at e [ p o n to to , l a b e l = b e l ow ow : B ] ( B ) a t ( 1 , 0 ) ; \ c o o r d i n at at e [ p o n to to , l a b e l = b e l ow ow : C ] ( C ) a t ( 3 , 0 ) ; \ c o o r d i n at at e [ p o n to to , l a b e l = r i g ht ht : D ] ( D ) a t ( 4 , 1 ) ; \ c o o r d i n at at e [ p o n to to , l a b e l = r i g ht ht : E ] ( E ) a t ( 4 , 3 ) ; \ c o o r d i n at at e [ p o n to to , l a b e l = a b o ve ve : F ] ( F ) a t ( 3 , 4 ) ; \ c o o r d i n at at e [ p o n to to , l a b e l = a b o ve ve : G ] ( G ) a t ( 1 , 4 ) ; \ c o o r d i n at at e [ p o n to to , l a b e l = l e ft ft : H ] ( H ) a t ( 0 , 3 ) ; \ c o o r d i n at at e [ p o n to to , l a b e l = l e ft ft : I ] ( I ) a t ( 6 , 2 ) ; \ c o o r d i n at at e [ p o n to to , l a b e l = a b o ve ve : J ] ( J ) a t ( 8 , 3 ) ; \ c o o r d i n at at e [ p o n to to , l a b e l = b e l ow ow : K ] ( K ) a t ( 8 , 0 ) ; % to \ d r aw aw ( A ) t o [ ou ou t = - 90 90 , i n = 18 18 0 ] ( B ) ; \ d r aw aw ( C ) t o [ ou ou t =0 = 0 , i n = - 90 90 ] ( D ) ; \ d r aw aw ( E ) t o [ ou ou t = 90 90 , i n = 0] 0] ( F ) ; \ d r aw aw ( G ) t o [ ou ou t = 18 18 0 , i n = 90 90 ] ( H ) ; \ dr d r aw aw [ da d a sh s h ed ed ] ( B) B ) - - ( C ) ( D) D ) - - ( E ) ( F) F ) - - ( G ) ( H) H ) - - ( A ); ); \ d r aw aw ( I ) t o [ ou ou t = 45 45 , i n = 2 25 25 ] ( J ) t o [ ou ou t = 45 45 , i n = 0] 0 ] ( K ) t o [ ou o u t = 18 18 0 , i n = 22 22 5 ] ( I ) ; \ en d { t i k z p i c t u r e }
R´egis
2011
http://latexbr.blogspot.com/
4
Veja mais um exemplo com uma figura conhecida: arcos g´oticos.
Figura 5: Arcos g´oticos. oticos. \ begin { t i k z p i c t u r e } \ d r a w [ b l ue ue ] ( 0 , 0 ) t o [ o u t = 90 90 , i n = 2 2 5 ] ( 1 , 2 ) t o [ o u t = - 4 5 , i n = 9 0] 0] ( 2 , 0 ) ; \ d r a w [ b r o wn wn ] ( 3 , 0 ) t o [ o u t = 9 0 , i n = - 9 0] 0 ] ( 4 , 2 ) t o [ o u t = - 9 0 , i n = 9 0] 0] ( 5 , 0 ) ; \ en d { t i k z p i c t u r e }
Veja tamb´ t amb´em em os exemplo exem ploss Clusters Clusters of atoms atoms e Beamer arrows.
Bend Existem dois operadores: bend left e bend right. Ambos s˜ao ao usados como op¸c˜ cao a˜o para o operador to. O bend left funciona left=45, o resultado ser´ funcion a da seguinte forma: f orma: se vocˆe digitar digita r bend left=45 a equivalente right funciona de forma angulo>, angulo>,in=1 in=180 80 - <^angulo> angulo>. O bend right a out=45,in=135. Ou sej seja, a, out=<^ contr´aria. aria. 45
90
◦
A H
B
C
J
G
I
E L
bend right
bend left
D
F N bend right
bend left
K
◦
M
Figura 6: Exemplo do operador bend. \ begin { t i k z p i c t u r e } \ t i k z s t y l e { p o n t o } = [fill [ fill = b l u e , c i r c l e ,scale , scale =.25] \ c o o r d i n at at e [ p o n to to , l a b e l = b e l ow ow : A ] ( A ) a t ( 0 , 3 ) ; \ c o o r d i n at at e [ p o n to to , l a b e l = b e l ow ow : B ] ( B ) a t ( 2 , 3 ) ; \ c o o r d i n at at e [ p o n to to , l a b e l = b e l ow ow : C ] ( C ) a t ( 3 , 3 ) ; \ c o o r d i n at at e [ p o n to to , l a b e l = b e l ow ow : D ] ( D ) a t ( 5 , 3 ) ; \ c o o r d i n at at e [ p o n to to , l a b e l = b e l ow ow : E ] ( E ) a t ( 6 , 3 ) ; \ c o o r d i n at at e [ p o n to to , l a b e l = b e l ow ow : F ] ( F ) a t ( 8 , 3 ) ; \ c o o r d i n at at e [ p o n to to , l a b e l = l e ft ft : G ] ( G ) a t ( 0 , 0 ) ; \ c o o r d i n at at e [ p o n to to , l a b e l = l e ft ft : H ] ( H ) a t ( 0 , 2 ) ; \ c o o r d i n at at e [ p o n to to , l a b e l = l e ft ft : I ] ( I ) a t ( 2 , 0 ) ; \ c o o r d i n at at e [ p o n to to , l a b e l = l e ft ft : J ] ( J ) a t ( 2 , 2 ) ; \ c o o r d i n at at e [ p o n to to , l a b e l = b e l ow ow : K ] ( K ) a t ( 3 , 0 ) ; \ c o o r d i n at at e [ p o n to to , l a b e l = r i g ht ht : L ] ( L ) a t ( 5 , 2 ) ; \ c o o r d i n at at e [ p o n to to , l a b e l = b e l ow ow : M ] ( M ) a t ( 6 , 0 ) ;
R´egis
2011
http://latexbr.blogspot.com/
5
\ c o o r d i n at at e [ p o n to to , l a b e l = r i g ht ht : N ] ( N ) a t ( 8 , 2 ) ; %bend \ d r aw aw ( A ) t o [ be b e n d l ef ef t ] ( B ) ; \ d r aw aw ( C ) t o [ be b e n d l ef e f t = 4 5] 5] ( D ) ; \ d r aw aw ( E ) t o [ be b e n d l ef e f t = 9 0] 0] ( F ) ; \ d r aw aw [ - > ] ( G ) t o [ be b e nd n d l ef ef t ] ( H ) ; \ d r aw aw [ - > ] ( I ) t o [ be b e nd n d r i gh gh t = 6 0] 0] ( J ) ; \ d r aw aw [ - > ] ( K ) t o [ be b e nd n d l ef ef t ] ( L ) ; \ d r aw aw [ - > ] ( M ) t o [ be b e nd n d r i gh gh t ] ( N ) ; \ node a t ( 4 , 4 ) { $ 4 5^ 5^ \ c i r c $ } ; \ node a t ( 7 , 4 ) { $ 9 0^ 0^ \ c i r c $ } ; \ node [ l e ft ft ] a t ( - . 5 ,1 ,1 ) { b e nd nd l ef ef t } ; \ node a t ( 1. 1 . 5 , 1) 1 ) { b e nd nd r i gh gh t } ; \ node a t ( 4. 4 . 5 , 1) 1 ) { b e nd nd l e ft ft } ; \ node a t ( 9 , 1) 1) { b e nd nd r i gh gh t } ; \ en d { t i k z p i c t u r e }
Veja mais um exemplo: fios de postes.
Figura 7: Fios do poste feito com bend. \ begin { t i k z p i c t u r e } \ d r aw aw ( - 1 ,0 ,0 ) - - ( 5 , 0 ) ; %postes \ fill ( 0 ,0 ,0 ) - - + +( +( 0 ,2 , 2 ) - - + +( +( - .1 .1 , 0) 0 ) - - + +( + ( 0 ,. , . 1) 1) - - + +( +( .4 . 4 , 0) 0 ) - - + +( +( 0 , -. - . 1) 1) - + +( + ( - . 1 , 0) 0) - - + +( + ( 0 , - 2) 2) - - c yc yc l e ; \ fill ( 2 ,0 ,0 ) - - + +( +( 0 ,2 , 2 ) - - + +( +( - .1 .1 , 0) 0 ) - - + +( + ( 0 ,. , . 1) 1) - - + +( +( .4 . 4 , 0) 0 ) - - + +( +( 0 , -. - . 1) 1) - + +( + ( - . 1 , 0) 0) - - + +( + ( 0 , - 2) 2) - - c yc yc l e ; \ fill ( 4 ,0 ,0 ) - - + +( +( 0 ,2 , 2 ) - - + +( +( - .1 .1 , 0) 0 ) - - + +( + ( 0 ,. , . 1) 1) - - + +( +( .4 . 4 , 0) 0 ) - - + +( +( 0 , -. - . 1) 1) - + +( + ( - . 1 , 0) 0) - - + +( + ( 0 , - 2) 2) - - c yc yc l e ; %fios \ d r aw aw [ b l ue ue ] ( .2 . 2 5 , 2) 2 ) t o [ be b e n d r ig i g h t ] ( 1. 1 . 9 5 , 2) 2) ; \ d r aw aw [ b l ue ue ] ( 2 .2 .2 5 , 2) 2 ) t o [ be b e nd n d r i gh gh t ] ( 3 .9 .9 5 , 2 ) ; \ en d { t i k z p i c t u r e }
Veja mais exemplos do uso de bend em EPC Flow Charts e Mobile ad-hoc network.
R´egis
2011
http://latexbr.blogspot.com/
6
Smooth Esta op¸c˜ c˜ao ao faz com que os pontos de uma curva sejam conectados por uma curva suave. Mas esta op¸c˜ cao a˜o s´o ´e usada u sada com o operado o peradorr plot e coordinates . Um exemplo simples ´e: e: \draw[smo \draw[smooth] oth] plot coordina coordinates tes {(0,0) {(0,0) (1,1) (1,1) (2,0) (2,0) (3,1)}; (3,1)};
No caso eu usei 4 pontos, mas pode ser qualquer quantidade a partir de 2 pontos. Temos tamb´em em a op¸c˜ caao ˜o tension, que permite permite um ajuste na curva curva suavizando suavizando os cantos. Veja na figura a seguir um exemplo com 4 pontos (esquerda) e um exemplo da mesma curva com v´arias v´arias tens˜oes oes diferentes. tension=1.5
B
D
tension=1
F
tension=default tension=0
A
C
E
G
Figura 8: Exemplo de smooth. \ begin { t i k z p i c t u r e } [ > = l a t e x ] \ t i k z s t y l e { p o n t o } = [fill [ fill = b l u e , c i r c l e ,scale , scale =.25] \ c o o r d i n at at e [ p o n to to , l a b e l = b e l ow ow : A ] ( A ) a t ( 0 , 0 ) ; \ c o o r d i n at at e [ p o n to to , l a b e l = a b o ve ve : B ] ( B ) a t ( 1 , 1 ) ; \ c o o r d i n at at e [ p o n to to , l a b e l = b e l ow ow : C ] ( C ) a t ( 2 , 0 ) ; \ c o o r d i n at at e [ p o n to to , l a b e l = a b o ve ve : D ] ( D ) a t ( 3 , 1 ) ; \ c o o r d i n at at e [ p o n to to , l a b e l = b e l ow ow : E ] ( E ) a t ( 4 , 0 ) ; \ c o o r d i n at at e [ p o n to to , l a b e l = a b o ve ve : F ] ( F ) a t ( 6 , 1 ) ; \ c o o r d i n at at e [ p o n to to , l a b e l = b e l ow ow : G ] ( G ) a t ( 8 , 0 ) ; \ d ra ra w [r [ r ed ed , d as a s he he d , v er e r y t hi hi n ] ( A ) - - ( B ) - - ( C ) - - ( D ); ); \ d ra ra w [ re r e d , d as a s he he d , v er er y t hi h i n ] ( E ) - - ( F ) - - ( G ); ); %smooth \ d r aw aw [ s m o ot ot h ] p l ot ot c o o rd rd i na n a t es e s { ( A ) ( B ) ( C ) ( D ) }; }; \ d r aw aw [ s m o ot ot h ] p l ot ot c o o rd rd i na n a t es e s { ( E ) ( F ) ( G ) }; }; \ d r a w [ s m o o t h ,tension , tension = 1 , bl b l u e ] p lo l o t c o or o r d in i n a te t e s { ( E) E ) ( F ) ( G ) }; }; \ d r a w [ s m o o t h ,tension , tension = 1. 1. 5 , b r ow ow n ] p lo l o t c o or o r d in i n a te t e s { ( E) E ) ( F ) ( G ) }; }; %setas \ d r aw aw [ < - ] ( 7 , .8 . 8 5) 5 ) - - ( 7. 7 . 5 , 2) 2 ) node [ r i g h t ] { \ f o o t n o te te s i z e tension =1.5}; \ d r aw aw [ < - ] ( 7 .2 .2 , . 6 5) 5) - - ( 8 , 1. 1 . 5) 5 ) node [ r i g h t ] { \ f o o t n o t es es i z e tension =1}; \ d r aw aw [ < - ] ( 7 .3 .3 , . 4 5) 5) - - ( 8. 8 . 5 , 1) 1 ) node [ r i g h t ] { \ f o o t n o t es es i z e tension = d e f a u l t } ; \ d r aw aw [ < - ] ( 7. 7 . 4 , . 3) 3) - - ( 9 , .5 .5 ) node [ r i g h t ] { \ f o o t n o te te s i z e tension =0}; \ en d { t i k z p i c t u r e }
R´egis
2011
http://latexbr.blogspot.com/
7
A seguir um outro exemplo com diferentes tens˜oes mas desta vez usando a op¸c˜aaoo smooth smooth cycle cycle . Esta op¸c˜ c˜ao ao fecha o ciclo de uma figura aberta transformando-a numa figura fechada. B
A
F
C
E
J
G
I
K
D
H
L
tension=0.2
tension=0.5
tension=1
Figura 9: Exemplo de smooth cycle. \ begin { t i k z p i c t u r e } \ t i k z s t y l e { p o n t o } = [fill [ fill = b l u e , c i r c l e ,scale , scale =.25] \ c o o r d i n at at e [ p o n to to , l a b e l = l e ft ft : A ] ( A ) a t ( 0 , 0 ) ; \ c o o r d i n at at e [ p o n to to , l a b e l = a b o ve ve : B ] ( B ) a t ( 1 , 1 ) ; \ c o o r d i n at at e [ p o n to to , l a b e l = r i g ht ht : C ] ( C ) a t ( 2 , 0 ) ; \ c o o r d i n at at e [ p o n to to , l a b e l = b e l ow ow : D ] ( D ) a t ( 1 , - 1 ) ; \ c o o r d i n at at e [ p o n to to , l a b e l = l e ft ft : E ] ( E ) a t ( 4 , 0 ) ; \ c o o r d i n at at e [ p o n to to , l a b e l = a b o ve ve : F ] ( F ) a t ( 5 , 1 ) ; \ c o o r d i n at at e [ p o n to to , l a b e l = r i g ht ht : G ] ( G ) a t ( 6 , 0 ) ; \ c o o r d i n at at e [ p o n to to , l a b e l = b e l ow ow : H ] ( H ) a t ( 5 , - 1 ) ; \ c o o r d i n at at e [ p o n to to , l a b e l = l e ft ft : I ] ( I ) a t ( 8 , 0 ) ; \ c o o r d i n at at e [ p o n to to , l a b e l = a b o ve ve : J ] ( J ) a t ( 9 , 1 ) ; \ c o o r d i n at at e [ p o n to to , l a b e l = r i g ht ht : K ] ( K ) a t ( 1 0 , 0 ) ; \ c o o r d i n at at e [ p o n to to , l a b e l = b e l ow ow : L ] ( L ) a t ( 9 , - 1 ) ; % s m o o t h c y c le le \ d r aw aw [ s m o ot ot h c y cl cl e ] p l ot ot [ tension = 0 .2 .2 ] c o o rd rd i na n a t es e s { ( A ) ( B ) ( C ) ( D ) }; }; \ d r a w [ s m o ot ot h c y cl cl e , y s h i ft ft = - 2 .2 .2 5 c m ] plot[ tension = 0 .5 .5 ] c o or o r d in i n a t es es { ( E ) ( F ) ( G ) ( H ) }; }; \ d r a w [ s m o ot ot h c y cl cl e , y s h i ft ft = - 4 .5 .5 c m ] plot[ tension = 1] 1 ] c o or o r d in i n a te te s { ( I ) ( J ) ( K ) ( L ) }; }; %texto \ node a t ( 1 , - 2) 2) { tension =0.2}; \ node a t ( 5 , - 2) 2) { tension =0.5}; \ node a t ( 9 , - 2) 2) { tension =1}; \ en d { t i k z p i c t u r e }
R´egis
2011
http://latexbr.blogspot.com/
8
Mais um exemplo: exemplo:
Figura 10: Carro feito com smooth cycle. \ begin { t i k z p i c t u r e } [ x = . 5 , y = . 5 ] \ d r a w [ s m o ot ot h c y cl cl e , tension = . 5 5] 5] p l o t c o o r d i n a t es es { ( 2 0 , 4 5) 5) ( 7 0 , 3 6 ) ( 8 0 , 4 0) 0) ( 8 5 , 8 0 ) ( 1 1 0 , 1 0 0) 0) ( 1 5 0 , 1 00 00 ) ( 1 7 0 , 8 0 ) ( 1 78 78 , 6 0 ) ( 1 8 5 , 4 0 ) ( 2 30 30 , 3 8 ) ( 4 0 0 , 3 8 ) ( 4 40 40 , 4 2 ) ( 4 5 5 , 8 0 ) ( 4 7 8 , 1 02 02 ) ( 5 1 4 , 1 0 2 ) ( 5 30 30 , 9 0 ) ( 5 42 42 , 7 0 ) ( 5 4 5 , 4 8 ) ( 5 55 5 5 , 4 9 ) ( 5 7 3 , 6 0 ) ( 5 7 7 , 8 0) 0) ( 5 77 77 , 9 5 ) ( 5 6 5 , 1 1 0 ) ( 5 6 3 , 1 50 50 ) ( 5 5 5 , 1 7 0 ) ( 4 80 80 , 2 1 7 ) ( 3 7 0 , 2 22 22 ) ( 2 8 0 , 2 1 5 ) ( 1 75 75 , 1 5 7 ) ( 4 0 , 1 2 0 ) ( 2 3 , 1 00 00 ) (20,90) }; \ d r a w [ s m o ot ot h c y cl cl e , tension = . 5 5] 5] p l o t c o o r d i n a t es es { ( 1 8 5 , 1 45 45 ) ( 4 0 0 , 1 5 5 ) ( 5 10 10 , 1 6 5 ) ( 4 6 5 , 2 0 5) 5) ( 4 1 5 , 2 1 2 ) ( 3 0 0 , 2 1 0) 0) }; \ d r aw aw ( 1 30 30 , 5 0 ) c i rc rc l e ( 42 42 ) ; \ d r aw aw ( 4 95 95 , 5 0 ) c i rc rc l e ( 42 42 ) ; \ en d { t i k z p i c t u r e }
Veja os videos smooth carro 01 e smooth carro 02 no youtube. Veja um exemplo de smooth em Temperature and rain sparklines.
R´egis
2011
http://latexbr.blogspot.com/
9
Compara¸ c˜ cao a ˜o entre out, in, bend e smooth Veja um compara¸c˜ c˜ao ao entre as curvas com o uso de out, in, bend e smooth.
bend right
out,in
smooth
Figura 11: Compara¸c˜ c˜ao ao entre out, in, bend e smooth \ begin { t i k z p i c t u r e } \ t i k z s et et { > = l a t ex ex , i n n e r s e p = 0 pt pt , o u t e r s e p = 2 pt pt } %bend \ d r aw aw [ r e d ] ( 0 , 0 ) t o [ b e nd nd r i gh gh t ] ( 2 , 2) 2) ; %out,in \ d r aw aw [ g r ee e e n ] ( 0 , 0) 0) t o [ o u t =0 =0 , i n = - 90 90 ] ( 2 , 2) 2) ; %smooth \ d r a w [ b l u e , s m o o t h ,tension , tension = . 5] 5] p lo l o t c o or o r d in i n a te t e s { (0 ( 0 , 0 ) ( 1 .7 .7 5 , . 25 25 ) ( 2 , 2) 2) } % t e xt x t o s e f l ec ec h as as \ d r a w [ - > ] ( . 5 , 1 . 5) 5) node [ a b ov ov e ] { \ t in in y b en e n d r i gh gh t } t o [ o u t = - 9 0 , i n = 1 3 5 ] ( 1 .3 .3 , . 7 ) ; \ d r a w [ - > ] ( 0 , 1 ) node [ l e ft ft ] { \ t in in y o ut ut , i n } t o [ o u t = 0 , i n = 1 3 5 ] ( 1 . 2 , . 4) 4) ; \ d r a w [ - > ] ( 2 .5 .5 , 1 ) node [ r i gh g h t ] { \ t in in y s m oo oo t h } t o [ o u t = 1 8 0 , i n = 0 ] ( 1 . 9 , . 5) 5) ; % b o l i n h as as a z u is is \ fill [ b l ue ue ] ( 0 , 0) 0) c i rc rc l e ( 1 pt pt ) ; \ fill [ b l ue ue ] ( 1 .7 .7 5 , . 25 25 ) c i rc rc l e ( 1 pt pt ) ; \ fill [ b l ue ue ] ( 2 , 2) 2) c i rc rc l e ( 1 pt pt ) ; \ en d { t i k z p i c t u r e }
R´egis
2011
http://latexbr.blogspot.com/
10
B´ ezie ez ier r - control cont rolss controle O operador se chama controls. B´ezier ´e um tipo de curva curva definida definida por pontos de controle que determinam sua curvatura. curvatura . Podemos definir as curvas B´ ezier ezier de duas maneiras: por coordenadas polares ou por coordenadas cartesianas.
Coordenadas Polares Considere os pontos P1 e P2 da figura a seguir como os pontos de in´ıcio e fim da curva, e considere os pontos C1 e C2 como pontos de controle que definem a curvatura da curva. Suponha uma reta suporte passando por P1 e C1 e outra passando por P2 e C2. Essas retas retas tangenciam tangenciam a curva curva em P1 e P2 definindo assim a curvatura da curva. ponto de controle
Curva Cu rva B´ezier ezi er
C2 raio ponto de controle
r2
C1
reta tangente a curva em P2
r1
ponto inicial
α
β
P1
P2 reta tangente a curva em P1
ˆangulo angulo ponto final
Figura 12: Curva B´ ezier ezier definida por coordenadas polares. p olares. A sintaxe si ntaxe para pa ra gerar ger ar uma curva B´ezier ezier usando coordenadas coord enadas polares pola res ´e a seguinte: draw (P1) (P1) .. cont contro rols ls +(α : r1 ) and +(β : r2 ) .. (P2) (P2); ; \draw
onde P1 ´e o ponto inicial, inicia l, P2 ´e o ponto po nto final, fina l, α e β s˜ao a o os ˆangulos angulos de inclina¸c˜ cao ˜ao das retas tangentes a P1 e P2, respectivamente; e r1 e r2 ´e o comprimento de cada reta tangente, ou seja, a distˆancia de P1 ` a C1 e P2 `a C2, respectivamente.
R´egis
2011
http://latexbr.blogspot.com/
11
Exemplo com coordenadas polares
Veja o c´odigo odigo mais simples para gera¸c˜ cao a˜o da curva B´ezier ezier em coordenadas polares. \ begin { t i k z p i c t u r e } \ d r aw aw ( 0 , 0) 0) . . c o nt n t r ol ol s + ( 45 45 : 1) 1) a nd n d + ( 60 60 : 2) 2) . . ( 2 , 0 ) ; \ en d { t i k z p i c t u r e }
C2
C1
45
60
◦
P1
◦
P2 resultado final Figura 13: Exemplo de curva B´ ezier ezier definida por coordenadas polares.
A seguir um c´odigo odigo mais completo com o uso de coordenadas previamente definidas e estilos para visualiza¸c˜ c˜ao ao dos pontos. Mas lembrando que, o c´odigo odigo anterior ´e suficiente para gerar a curva. \ begin { t i k z p i c t u r e } % d e f in in i ca c a o d e e s ti ti l os os \tikzset{>=latex, p o n t o / . s t y l e = { d r a w ,fill ,fill =blue, rectangle , scale =.5}, c o n t r o l e / . s t y l e = { d r a w , b l u e , c i r c l e ,scale ,scale =.5} } %coordenadas \ c o o r d i n at at e [ p o n to to , l a b e l = b e l ow ow : P 1 ] ( p 1 ) a t ( 0 , 0 ) ; \ c o o r d i n at at e [ p o n to to , l a b e l = b e l ow ow : P 2 ] ( p 2 ) a t ( 2 , 0 ) ; \ c o o r d i n at at e [ c o n t ro ro l e , l a b e l = a b o ve ve : C 1 ] ( c 1 ) a t ( 4 5 : 1) 1) ; \ c o o rd rd i na n a t e ( c 2 ) a t ( 6 0: 0: 2 ) ; % c o o rd rd e na n a d a n e ce c e s sa s a r ia i a p a ra ra p o si si c ao ao c o rr rr e ta ta d o p o nt nt o c c 2 p a r a d e se s e n ha ha r a r et et a tangente. % N ao a o e h o b ri r i g at a t o ri ri o . \ c o o r d i n at at e [ c o n t ro ro l e , , l a b e l = a b o ve ve : C 2 , x s h i f t = 4 c m ] ( c c 2 ) a t ( c 2 ) ; % x sh s h if i f t c om om o d o br br o d a p o si si c ao ao d o p o nt nt o . %retas \ d ra ra w [ bl bl ue ue ] ( p 1) 1) - - ( c 1) 1) ( p 2) 2) - - ( c c 2 ); ); %bezier \ d ra ra w ( p 1) 1) . . c on o n tr t r ol o l s + (c ( c 1) 1 ) a nd nd + ( c2 c 2 ) . . ( p 2) 2) ; \ en d { t i k z p i c t u r e }
R´egis
2011
http://latexbr.blogspot.com/
12
Coordenadas Cartesianas Atrav´es es de coordenadas coord enadas cartesianas cartesi anas os o s pontos p ontos P1, P2, C1 e C2 s˜ao ao definidos pelo par ordenado ( x, y ). pontos de controle y
C1
ponto inicial
C2
Curva Cu rva B´ezier ezi er P1
P2
ponto final x
0
Figura 14: Curva B´ezier ezier definida por coordenadas cartesianas. A sintaxe si ntaxe para pa ra gerar ger ar uma curva B´ezier ezier usando coordenadas coord enadas cartesianas cartesi anas ´e a seguinte: draw (P1) (P1) .. cont contro rols ls (C1) (C1) and and (C2) (C2) .. \draw
(P2) (P2); ;
onde P1 ´e o ponto inicial, inici al, P2 ´e o ponto po nto final, final , C1 e C2 s˜ ao os pontos de controle. ao Exemplo com coordenadas cartesianas
Uma curva cu rva B´ezier ezier pode po de ser definida por um ou dois pontos de controle para cada trecho de curva. Veja o c´odigo odigo mais simples para gera¸c˜ c˜ao ao da curva B´ezier ezier em coordenadas cartesianas, no caso, com um ponto de controle. \ begin { t i k z p i c t u r e } \ d r aw aw ( 0 , 0) 0) . . c o nt n t r ol ol s ( 1 , 2) 2) . . ( 4 , 0 ) ; \ en d { t i k z p i c t u r e }
C1
P1
P2 resultado final Figura 15: Curva B´ezier ezier com um ponto p onto de controle.
A seguir um c´odigo odigo mais completo com o uso de coordenadas previamente definidas e estilos para visualiza¸c˜ cao ˜ao dos pontos.
R´egis
2011
http://latexbr.blogspot.com/
13
\ begin { t i k z p i c t u r e } \tikzset{>=latex, p o n t o / . s t y l e = { d r a w ,fill ,fill =blue, rectangle , scale =.5}, c o n t r o l e / . s t y l e = { d r a w , b l u e , c i r c l e ,scale ,scale =.5} } %grade \ d r a w [ c o l o r = l i g ht ht g r ay ay , d a s h e d ] ( 0 , 0 ) g r i d ( 4 , 3 ) ; %coordenadas \ c o o r d i n at at e [ p o n to to , l a b e l = b e l ow ow : P 1 ] ( p 1 ) a t ( 0 , 0 ) ; \ c o o r d i n at at e [ p o n to to , l a b e l = b e l ow ow : P 2 ] ( p 2 ) a t ( 4 , 0 ) ; \ c o o r d i n at at e [ c o n t ro ro l e , l a b e l = a b o ve ve : C 1 ] ( c 1 ) a t ( 1 , 2 ) ; %retas \ d ra ra w [ bl bl ue ue ] ( p 1) 1) - - ( c 1) 1) - - ( p 2) 2) ; %bezier \ d ra ra w ( p 1) 1) . . c on o n tr t r ol o l s ( c 1) 1) . . ( p 2) 2) ; \ en d { t i k z p i c t u r e }
Se vocˆe quiser as coordenadas co ordenadas sem os estilos basta dar uma simplificada no c´odigo odigo anterior. \ begin { t i k z p i c t u r e } \ c o o rd rd i na n a t e ( p 1 ) a t ( 0 , 0) 0) ; \ c o o rd rd i na n a t e ( p 2 ) a t ( 4 , 0) 0) ; \ c o o rd rd i na n a t e ( c 1 ) a t ( 1 , 2) 2) ; %bezier \ d ra ra w ( p 1) 1) . . c on o n tr t r ol o l s ( c 1) 1) . . ( p 2) 2) ; \ en d { t i k z p i c t u r e }
Curva com dois pontos de controle
A seguir, uma curva com dois pontos de controle. Repare o uso do operador and. \ begin { t i k z p i c t u r e } \ d ra ra w ( 0 ,0 ,0 ) . . c on o n tr t r ol o l s ( 1 ,2 ,2 ) a nd nd ( 2 ,2 ,2 ) . . ( 4 ,0 ,0 ) ; \ en d { t i k z p i c t u r e }
C1
P1
C2
P2 resultado final Figura 16: Curva B´ezier ezier com dois pontos de controle.
\ begin { t i k z p i c t u r e } \tikzset{>=latex, p o n t o / . s t y l e = { d r a w ,fill ,fill =blue, rectangle , scale =.5}, c o n t r o l e / . s t y l e = { d r a w , b l u e , c i r c l e ,scale ,scale =.5} } %grade \ d r a w [ c o l o r = l i g ht ht g r ay ay , d a s h e d ] ( 0 , 0 ) g r i d ( 4 , 3 ) ;
R´egis
2011
http://latexbr.blogspot.com/
14
%coordenadas \ c o o r d i n at at e [ p o n to to , l a b e l = b e l ow ow : P 1 ] ( p 1 ) a t ( 0 , 0 ) ; \ c o o r d i n at at e [ p o n to to , l a b e l = b e l ow ow : P 2 ] ( p 2 ) a t ( 4 , 0 ) ; \ c o o r d i n at at e [ c o n t ro ro l e , l a b e l = a b o ve ve : C 1 ] ( c 1 ) a t ( 1 , 2 ) ; \ c o o r d i n at at e [ c o n t ro ro l e , l a b e l = a b o ve ve : C 2 ] ( c 2 ) a t ( 2 , 2 ) ; %retas \ d ra ra w [ bl bl ue ue ] ( p 1) 1) - - ( c 1) 1) ( p 2) 2) - - ( c 2 ) ; %bezier \ d ra ra w ( p 1) 1) . . c on o n tr t r ol o l s ( c 1) 1) a nd nd ( c 2) 2) . . ( p 2) 2) ; \ en d { t i k z p i c t u r e }
E o c´odigo odigo somente somente com as coordenadas: coordenadas: \ begin { t i k z p i c t u r e } \ c o o rd rd i na n a t e ( p 1 ) a t ( 0 , 0) 0) ; \ c o o rd rd i na n a t e ( p 2 ) a t ( 4 , 0) 0) ; \ c o o rd rd i na n a t e ( c 1 ) a t ( 1 , 2) 2) ; \ c o o rd rd i na n a t e ( c 2 ) a t ( 2 , 2) 2) ; %bezier \ d ra ra w ( p 1) 1) . . c on o n tr t r ol o l s ( c 1) 1) a nd nd ( c 2) 2) . . ( p 2) 2) ; \ en d { t i k z p i c t u r e }
Exemplo de duas curvas
Daqui pra frente sempre usaremos coordenadas previamente definidas e estilos para visualiza¸c˜ aaoo dos pontos. Para fazer duas curvas basta inserir um novo controls. Assim, teremos: draw (P1) (P1) .. cont contro rols ls (C1) (C1) and and (C2) (C2) .. \draw ..
C1
(P2) (P2) (P3) (P3); ;
cont contro rols ls (C3) (C3) and and (C4) (C4) .. ..
C2 P3
P1
P2 C3
C4
resultado final
Figura 17: Duas curvas B´ezier. ezier. \ begin { t i k z p i c t u r e } \tikzset{>=latex, p o n t o / . s t y l e = { d r a w ,fill ,fill =blue, rectangle , scale =.5}, c o n t r o l e / . s t y l e = { d r a w , b l u e , c i r c l e ,scale ,scale =.5} } %grade \ d r a w [ c o l o r = l i g ht ht g r ay ay , d a s h e d ] ( 0 , - 2 ) g r id id ( 6 , 2 ) ; %coordenadas \ c o o r d i n at at e [ p o n to to , l a b e l = b e l ow ow : P 1 ] ( p 1 ) a t ( 0 , 0 ) ; \ c o o r d i n at at e [ p o n to to , l a b e l = b e l ow ow l e ft ft : P 2 ] ( p 2 ) a t ( 3 , 0 ) ; \ c o o r d i n at at e [ p o n to to , l a b e l = a b o ve ve : P 3 ] ( p 3 ) a t ( 6 , 0 ) ;
R´egis
2011
http://latexbr.blogspot.com/
15
\ c o o r d i n at at e [ c o n t ro ro l e , l a b e l = a b o ve ve : C 1 ] ( c 1 ) a t ( 1 , 1 ) ; \ c o o r d i n at at e [ c o n t ro ro l e , l a b e l = a b o ve ve : C 2 ] ( c 2 ) a t ( 2 , 1 ) ; \ c o o r d i n at at e [ c o n t ro ro l e , l a b e l = b e l ow ow : C 3 ] ( c 3 ) a t ( 4 , - 1 ) ; \ c o o r d i n at at e [ c o n t ro ro l e , l a b e l = b e l ow ow : C 4 ] ( c 4 ) a t ( 5 , - 1 ) ; %retas \ d ra ra w [ bl bl ue ue ] ( p 1) 1) - - ( c 1 ) ( p 2 ) - - ( c 2 ) ( p 2 ) - - ( c 3 ) ( p 3 ) - - ( c 4 ); ); % d u as as c u rv rv a s b e zi zi e r \ dr d r aw aw ( p1 p 1 ) .. . . c o nt n t ro r o ls l s ( c 1) 1 ) a nd n d ( c 2) 2 ) . . ( p2 p2 ) . . c o nt nt ro r o ls l s ( c3 c 3 ) a n d ( c 4) 4) . . ( p3 p 3 ); ); \ en d { t i k z p i c t u r e }
Exemplo Exempl o de trˆ es es curvas
draw (P1) (P1) .. cont contro rols ls (C1) (C1) and and (C2) (C2) .. \draw .. ..
C1 C 2
P1
cont contro rols ls (C3 (C3) ) and and (C4) (C4) .. .. cont contro rols ls (C5) (C5) and and (C6) (C6) .. ..
(P2) (P2) (P3) (P3) (P4) (P4); ;
C5 C 6
P2
P3
P4
C3 C 4
resultado final Figura Fig ura 18: Trˆ es es curvas B´ezier. ezi er.
\ begin { t i k z p i c t u r e } \tikzset{>=latex, p o n t o / . s t y l e = { d r a w ,fill ,fill =blue, rectangle , scale =.5}, c o n t r o l e / . s t y l e = { d r a w , b l u e , c i r c l e ,scale ,scale =.5} } %grade \ d r a w [ c o l o r = l i g ht ht g r ay ay , d a s h e d ] ( 0 , - 2 ) g r id id ( 9 , 2 ) ; %coordenadas \ c o o r d i n at at e [ p o n to to , l a b e l = b e l ow ow : P 1 ] ( p 1 ) a t ( 0 , 0 ) ; \ c o o r d i n at at e [ p o n to to , l a b e l = b e l ow ow l e ft ft : P 2 ] ( p 2 ) a t ( 3 , 0 ) ; \ c o o r d i n at at e [ p o n to to , l a b e l = b e l ow ow r i g ht ht : P 3 ] ( p 3 ) a t ( 6 , 0 ) ; \ c o o r d i n at at e [ p o n to to , l a b e l = b e l ow ow : P 4 ] ( p 4 ) a t ( 9 , 0 ) ; \ c o o r d i n at at e [ c o n t ro ro l e , l a b e l = a b o ve ve : C 1 ] ( c 1 ) a t ( 1 , 1 ) ; \ c o o r d i n at at e [ c o n t ro ro l e , l a b e l = a b o ve ve : C 2 ] ( c 2 ) a t ( 2 , 1 ) ; \ c o o r d i n at at e [ c o n t ro ro l e , l a b e l = b e l ow ow : C 3 ] ( c 3 ) a t ( 4 , - 1 ) ; \ c o o r d i n at at e [ c o n t ro ro l e , l a b e l = b e l ow ow : C 4 ] ( c 4 ) a t ( 5 , - 1 ) ; \ c o o r d i n at at e [ c o n t ro ro l e , l a b e l = a b o ve ve : C 5 ] ( c 5 ) a t ( 7 , 1 ) ; \ c o o r d i n at at e [ c o n t ro ro l e , l a b e l = a b o ve ve : C 6 ] ( c 6 ) a t ( 8 , 1 ) ; %retas \ d ra ra w [ bl bl ue ue ] ( p 1) 1) - - ( c 1 ) ( p 2 ) - - ( c 2) 2 ) ( p 2) 2) - - ( c 3) 3 ) ( p 3) 3) - - ( c 4) 4 ) ( p 3) 3) - - ( c 5 ) ( p 4) 4) - - ( c 6 ) ; % t r es es c u rv rv a s b e zi zi e r \ dr d r aw aw ( p1 p 1 ) .. . . c o nt n t ro r o ls l s ( c 1) 1 ) a nd n d ( c 2) 2 ) . . ( p2 p2 ) . . c o nt nt ro r o ls l s ( c3 c 3 ) a n d ( c 4) 4) . . ( p3 p3 ) . . c o nt nt ro r o ls l s ( c5 c 5 ) a n d ( c 6) 6) . . ( p4 p 4 ); ); \ en d { t i k z p i c t u r e }
R´egis
2011
http://latexbr.blogspot.com/
16
Dica para desenhar desenha r curvas B´ ezier ezier
Uma boa dica para desenhar curvas B´ezier ezier ´e tra¸cando primeiro as retas com os quatro pontos da curva junto com uma grade, a partir da´ı teremos uma no¸c˜ao ao de como ser´a a curva. P2
P2
C2
C2
C1
C1
P1
P1 resultado final Figura 19: Exemplo
\ begin { t i k z p i c t u r e } \tikzset{>=latex, p o n t o / . s t y l e = { d r a w ,fill ,fill =blue, rectangle , scale =.5}, c o n t r o l e / . s t y l e = { d r a w , b l u e , c i r c l e ,scale ,scale =.5} } %grade \ d r a w [ c o l o r = l i g ht ht g r ay ay , d a s h e d ] ( 0 , 0 ) g r i d ( 2 , 4 ) ; %coordenadas \ c o o r d i n at at e [ p o n to to , l a b e l = b e l ow ow : P 1 ] ( p 1 ) a t ( 1 , 0 ) ; \ c o o r d i n at at e [ p o n to to , l a b e l = a b o ve ve : P 2 ] ( p 2 ) a t ( 1 , 4 ) ; \ c o o r d i n at at e [ c o n t ro ro l e , l a b e l = l e ft ft : C 1 ] ( c 1 ) a t ( 0 , 1 ) ; \ c o o r d i n at at e [ c o n t ro ro l e , l a b e l = l e ft ft : C 2 ] ( c 2 ) a t ( 0 , 3 ) ; %retas \ d ra ra w [r [ r ed ed , d a sh sh ed e d ] ( p 1) 1) - - ( c 1) 1) - - ( c 2) 2) - - ( p 2) 2) ; %bezier \ dr d r aw aw ( p1 p 1 ) .. . . c on on tr t r ol o l s ( c 1) 1) a n d ( c2 c 2 ) . . ( p2 p 2 ); ); \ en d { t i k z p i c t u r e }
R´egis
2011
http://latexbr.blogspot.com/
17
Vejamos agora mais alguns exemplos de curvas. P3
P3
C4
C4
C3
C3 P2
P1
P2
C2
C2
C1
C1
P1 resultado final Figura 20: Exemplo
\ begin { t i k z p i c t u r e } \tikzset{>=latex, p o n t o / . s t y l e = { d r a w ,fill ,fill =blue, rectangle , scale =.5}, c o n t r o l e / . s t y l e = { d r a w , b l u e , c i r c l e ,scale ,scale =.5} } %grade \ d r a w [ c o l o r = l i g ht ht g r ay ay , d a s h e d ] ( - 2 , 0 ) g r id id ( 2 , 6 ) ; %coordenadas \ c o o r d i n at at e [ p o n to to , l a b e l = b e l ow ow : P 1 ] ( p 1 ) a t ( 0 , 0 ) ; \ c o o r d i n at at e [ p o n to to , l a b e l = a b o ve ve r i g ht ht : P 2 ] ( p 2 ) a t ( 0 , 3 ) ; \ c o o r d i n at at e [ p o n to to , l a b e l = a b o ve ve : P 3 ] ( p 3 ) a t ( 0 , 6 ) ; \ c o o r d i n at at e [ c o n t ro ro l e , l a b e l = r i g ht ht : C 1 ] ( c 1 ) a t ( 1 , 1 ) ; \ c o o r d i n at at e [ c o n t ro ro l e , l a b e l = r i g ht ht : C 2 ] ( c 2 ) a t ( 1 , 2 ) ; \ c o o r d i n at at e [ c o n t ro ro l e , l a b e l = l e ft ft : C 3 ] ( c 3 ) a t ( - 1 , 4 ) ; \ c o o r d i n at at e [ c o n t ro ro l e , l a b e l = l e ft ft : C 4 ] ( c 4 ) a t ( - 1 , 5 ) ; %retas \ d ra ra w [r [ r ed ed , d a sh sh ed e d ] ( p 1) 1) - - ( c 1 ) - - ( c 2 ) - - ( p 2 ) - - ( c 3 ) - - ( c 4 ) - - ( p 3 ) ; %bezier \ dr d r aw aw ( p1 p 1 ) .. . . c o nt n t ro r o ls l s ( c 1) 1 ) a nd n d ( c 2) 2 ) . . ( p2 p2 ) . . c o nt nt ro r o ls l s ( c3 c 3 ) a n d ( c 4) 4) . . ( p3 p 3 ); ); \ en d { t i k z p i c t u r e }
R´egis
2011
http://latexbr.blogspot.com/
18
C1
P2 P1 C2
resultado final Figura 21: Exemplo
\ begin { t i k z p i c t u r e } \tikzset{>=latex, p o n t o / . s t y l e = { d r a w ,fill ,fill =blue, rectangle , scale =.5}, c o n t r o l e / . s t y l e = { d r a w , b l u e , c i r c l e ,scale ,scale =.5} } %grade \ d r a w [ c o l o r = l i g ht ht g r ay ay , d a s h e d ] ( 0 , - 1 ) g r id id ( 4 , 2 ) ; %coordenadas \ c o o r d i n at at e [ p o n to to , l a b e l = b e l ow ow : P 1 ] ( p 1 ) a t ( 0 , 0 ) ; \ c o o r d i n at at e [ p o n to to , l a b e l = a b o ve ve : P 2 ] ( p 2 ) a t ( 4 , 0 ) ; \ c o o r d i n at at e [ c o n t ro ro l e , l a b e l = a b o ve ve : C 1 ] ( c 1 ) a t ( 2 , 2 ) ; \ c o o r d i n at at e [ c o n t ro ro l e , l a b e l = b e l ow ow : C 2 ] ( c 2 ) a t ( 1 , - . 5 ) ; %retas \ d ra ra w [ bl bl ue ue ] ( p 1) 1) - - ( c 1) 1) ( p 2) 2) - - ( c 2 ) ; %bezier \ dr d r aw aw ( p1 p 1 ) .. . . c on on tr t r ol o l s ( c 1) 1) a n d ( c2 c 2 ) . . ( p2 p 2 ); ); \ en d { t i k z p i c t u r e }
R´egis
2011
http://latexbr.blogspot.com/
19
P2
C2
C1 P1 resultado final Figura 22: Exemplo \ begin { t i k z p i c t u r e } \tikzset{>=latex, p o n t o / . s t y l e = { d r a w ,fill ,fill =blue, rectangle , scale =.5}, c o n t r o l e / . s t y l e = { d r a w , b l u e , c i r c l e ,scale ,scale =.5} } %grade \ d r a w [ c o l o r = l i g ht ht g r ay ay , d a s h e d ] ( 0 , 0 ) g r i d ( 2 , 3 ) ; %coordenadas \ c o o r d i n at at e [ p o n to to , l a b e l = b e l ow ow : P 1 ] ( p 1 ) a t ( 0 , 0 ) ; \ c o o r d i n at at e [ p o n to to , l a b e l = a b o ve ve : P 2 ] ( p 2 ) a t ( 0 , 3 ) ; \ c o o r d i n at at e [ c o n t ro ro l e , l a b e l = a b o ve ve : C 1 ] ( c 1 ) a t ( 2 , 0 ) ; \ c o o r d i n at at e [ c o n t ro ro l e , l a b e l = b e l ow ow : C 2 ] ( c 2 ) a t ( 0 , 2 ) ; %retas \ d ra ra w [ bl bl ue ue ] ( p 1) 1) - - ( c 1) 1) ( p 2) 2) - - ( c 2 ) ; %bezier \ dr d r aw aw ( p1 p 1 ) .. . . c on on tr t r ol o l s ( c 1) 1) a n d ( c2 c 2 ) . . ( p2 p 2 ); ); \ en d { t i k z p i c t u r e }
R´egis
2011
http://latexbr.blogspot.com/
20
Veja tamb´em em uma compara¸c˜ao ao do carro desenhado anteriormente, s´o que agora desenhado com curvas B´ezier, ezier, no caso tivemos que inserir mais pontos de controle.
P1 P1 Figura 23: Carro desenhado com smooth (`a esquerda) es querda) e com c om B´ezier ezier (`a direita). Baixe o c´odigo odigo aqui. aqui. E por fim mais alguns exemplos exemplos de figuras figuras conhecidas. conhecidas. As vezes torna-se torna-se necess´ario ario uma altera¸c˜ caao ˜o na escala do desenho.
Figura 24: Letra B Baixe o c´odigo odigo aqui. aqui.
Figura 25: Gota d’´agua agua \ begin { t i k z p i c t u r e } [scale [ scale =.02] \draw[green ,dashed] (0,250) --(0,175) --(-65,130) --(-65,75) --(-65,20) --(-30,0) --(0,0)--(30,0) --(65,20) --(65,75) --(65,130) --(0 ,175) --(0,250); \ d r aw aw ( 0 , 25 25 0 ) . . c o nt n t r ol ol s ( 0 , 17 1 7 5) 5 ) a nd n d ( - 6 5 , 13 13 0) 0 ) . . ( - 6 5 ,7 ,7 5) 5) . . c o nt n t r ol ol s ( - 6 5 ,2 , 2 0) 0) a nd nd ( - 30 3 0 , 0 ) . . ( 0 , 0) 0) . . c o nt n t r ol ol s ( 30 3 0 , 0 ) a nd n d ( 65 6 5 , 2 0) 0 ) . . (6 (6 5 , 7 5) 5) . . c o nt n t r ol ol s ( 6 5 , 13 13 0 ) a nd nd ( 0 , 17 1 7 5) 5 ) . . ( 0 , 25 2 5 0) 0 ) - - c y cl cl e ; \ en d { t i k z p i c t u r e }
R´egis
2011
http://latexbr.blogspot.com/
21
P1 Figura 26: Garrafa \ begin { t i k z p i c t u r e } [scale [ scale =.5] \ d r aw aw ( - 1 .7 .7 , 0 ) . . c o nt n t r ol ol s ( - 1 , - .2 .2 5) 5) a nd n d ( 1 , - .2 .2 5) 5 ) . . ( 1 .7 .7 , 0 ) . . c on o n tr t r ol o l s ( 1. 1. 8 ,0 , 0 ) a n d ( 2 , .1 .1 ) . . ( 2 , .3 .3 ) - - ( 2 , 9) 9) . . c o nt n t r ol ol s ( 2 , 1 0. 0. 2 ) a nd nd ( .8 . 8 , 1 0 .5 .5 ) . . ( . 8 , 11 11 . 5) 5) - - ( . 8 , 1 5) 5) . . c o nt n t r ol ol s ( .5 . 5 , 1 5 .2 . 2 5 ) a nd n d ( - . 5 , 15 15 . 25 25 ) . . ( - . 8 ,1 ,1 5) 5) - - ( - . 8 , 1 1 . 5) 5) . . c o nt n t r ol ol s ( - . 8 , 10 10 .5 . 5 ) a nd n d ( - 2 , 1 0. 0. 2) 2 ) . . ( - 2 ,9 ,9 ) - - ( - 2 , .3 .3 ) . . c o nt n t r ol ol s ( - 2 , .1 .1 ) a nd n d ( - 1 .8 .8 , 0 ) . . ( - 1 .7 .7 , 0 ) ; \ en d { t i k z p i c t u r e }
R´egis
2011
http://latexbr.blogspot.com/
22
Figura 27: Ta¸ca ca Nesta figura eu escolhi usar uma reflex˜ao ao com o ambiente scope. \ begin { t i k z p i c t u r e } %grade \ d r a w [ l i g ht ht g r ay ay , o p a c i t y = .5 .5 , x s t e p = . 1 , y s t e p = . 1] 1] ( 0 , 0 ) g r i d ( 2 , 9 ) ; % e i xo xo d e s i me m e t ri ri a \ d r aw aw [ r e d ] ( 0 , 0) 0) - - + +( + ( 0 , 9) 9) ; %taca \ d r aw aw ( 0 , 0) 0) - - ( 1. 1 . 4 , 0) 0) . . c o nt n t r ol ol s ( 1. 1 . 4 , 0) 0 ) a nd n d ( 1. 1 . 9 , 0) 0 ) . . ( 1. 1 . 9 , . 2) 2) . . c o nt n t r ol ol s ( 1 .9 .9 , . 3 ) a nd nd ( 1 .6 .6 , . 2 ) . . ( 1. 1 . 5 , . 2) 2) . . c o nt n t r ol ol s ( 1 .3 .3 , . 2 ) a nd nd ( .2 . 2 , . 7) 7 ) . . ( . 2 , 1. 1. 1 ) - - ( . 2 , 3 . 5) 5) . . c o nt n t r ol ol s ( 1 , 4) 4) a nd nd ( 2. 2 . 3 , 5 .0 .0 ) . . ( 1 .5 .5 , 8 . 3) 3) - - ( 0 , 8 .3 .3 ) ; \ begin { s c o p e } [ x = - 1 c m ]% ] % - 1 p ro r o vo v o ca c a a r ef e f le l e xa x a o d a f ig i g ur u r a e m r el e l ac a c ao a o a o e ix ix o y . \ d r aw aw ( 0 , 0) 0) - - ( 1. 1 . 4 , 0) 0) . . c o nt n t r ol ol s ( 1. 1 . 4 , 0) 0 ) a nd n d ( 1. 1 . 9 , 0) 0 ) . . ( 1. 1 . 9 , . 2) 2) . . c o nt n t r ol ol s ( 1 .9 .9 , . 3 ) a nd nd ( 1 .6 .6 , . 2 ) . . ( 1. 1 . 5 , . 2) 2) . . c o nt n t r ol ol s ( 1 .3 .3 , . 2 ) a nd nd ( .2 . 2 , . 7) 7 ) . . ( . 2 , 1. 1. 1 ) - - ( . 2 , 3 . 5) 5) . . c o nt n t r ol ol s ( 1 , 4) 4) a nd nd ( 2. 2 . 3 , 5 .0 .0 ) . . ( 1 .5 .5 , 8 . 3) 3) - - ( 0 , 8 .3 .3 ) ; \ en d { s c o p e } \ en d { t i k z p i c t u r e }
R´egis
2011
http://latexbr.blogspot.com/
23
Figura 28: Android \ definecolor { v e r d e } { R G B } { 1 6 4 , 2 0 2 , 5 7 } \ begin { t i k z p i c t u r e } %grade \ d r a w [ l i g ht ht g r ay ay , d a s h e d ] ( - 5 , 0 ) g r i d ( 5 , 1 1 ) ; %eixo \ d r aw aw [ r e d ] ( 0 , 0) 0) - - ( 0 , 11 11 ) ; %corpo \ fill [ v e rd rd e ] ( - . 5 ,2 , 2 .1 . 1 ) - - ( .5 . 5 , 2 . 1) 1) - - ( . 5 ,. , . 5) 5 ) a rc r c ( 1 80 8 0 : 3 60 60 : 6. 6. 5 m m ) - - ( 1 .8 .8 , 2 . 1) 1) - - ( 2 .5 .5 , 2 . 1) 1) a rc r c ( 2 70 7 0 : 36 3 6 0 :5 :5 m m ) - - ( 3 , 7. 7. 3 ) - - ( - 3 , 7. 7 . 3) 3 ) - - ( - 3 , 2. 2 . 6) 6) a rc rc ( 1 80 8 0 : 27 2 7 0 :5 :5 m m ) - - ( - 1 .8 .8 , 2 .1 . 1 ) - - ( - 1 .8 .8 , . 5) 5) a rc rc ( 1 8 0: 0: 3 60 6 0 : 6. 6 . 5 m m ) - - c y cl cl e ; %bracos \ fill [ v e rd rd e , r o u n de de d c o r n er er s = 6 m m ] ( 3 . 35 35 , 3 . 2 ) r e c t a ng ng l e + + ( 1. 1. 4 , 4 . 2 ) ; \ fill [ v e rd rd e , r o u n de de d c o r n er er s = 6 m m ] ( - 3 . 3 5 , 3 .2 .2 ) r e c t an an g l e + + ( - 1 . 4 , 4 .2 .2 ) ; %cabeca \ fill [ v e rd rd e ] ( - 3 , 7. 7 . 5) 5 ) - - ( 3 , 7 . 5) 5) a rc r c ( 0 :1 :1 8 0: 0 : 3 ) - - c y cl cl e ; %olhos \ fill [ w h it it e ] ( 1 .4 .4 , 8 . 8) 8) c i rc rc l e ( 2 mm mm ) ; \ fill [ w h it it e ] ( - 1 .4 .4 , 8 .8 . 8 ) c i rc rc l e ( 2 mm mm ) ; %orelhas \ begin { s c o p e } [ x s h i f t = 1 . 4 c m , y s h i f t = 1 0 . 1 c m ] \ begin {scope}[ rotate =-35] \ fill [ v e rd rd e , r o u n de de d c o r n er er s = 0 . 4 5 m m ] ( 0 , 0 ) r e c t a ng ng l e + + ( .1 .1 , 1 ) ; \ en d { s c o p e } \ en d { s c o p e } \ begin { s c o p e } [ x s h i f t = - 1 . 4 c m , y s h i f t = 1 0 . 1 c m ] \ begin {scope}[ rotate =35] \ fill [ v e rd rd e , r o u n de de d c o r n er er s = 0 . 4 5 m m ] ( 0 , 0 ) r e c t a ng ng l e + + ( .1 .1 , 1 ) ; \ en d { s c o p e } \ en d { s c o p e } \ en d { t i k z p i c t u r e }
R´egis
2011
http://latexbr.blogspot.com/
24
Figura 29: Baleia Azul \ begin { t i k z p i c t u r e } \ fill [ c y an an ] ( 0 , 0) 0) . . c o nt nt r ol o l s ( 3 , 0) 0) a nd n d ( 8 , -5 - 5 ) . . ( 10 10 , 0 ) . . c o nt nt r ol o l s ( 9 , - .5 .5 ) a nd n d ( 8 .5 .5 , . 5) 5 ) . . ( 8 , 0) 0) . . c o nt nt r ol o l s ( 8 , .4 .4 ) a nd nd ( 9 .5 .5 , . 3 ) . . ( 10 1 0 , . 2) 2) . . c o nt nt r ol o l s ( 8 , 3) 3) a nd n d ( 0 , 2) 2) . . ( - 1 , 1. 1 . 5) 5) . . c o nt nt r ol o l s ( - 3 , .7 .7 ) a nd n d ( - 2 , 0) 0) . . ( - 4 , -1 -1 ) . . c o nt nt r ol o l s ( - 4 , -1 - 1 ) a nd n d ( - 2 , -2 - 2 ) . . ( 0 , 0) 0) ; \ fill [ c y an an ] ( 0 , 1. 1 . 7) 7 ) . . c o nt nt r ol o l s ( - 1 ,3 , 3 ) a nd n d ( - 2 , 3. 3 . 5) 5) . . ( - 3 , 3. 3. 5) 5) . . c o nt nt r ol o l s ( - 2 .5 .5 , 3 ) a nd n d ( - 2 .2 .2 , 2 ) . . ( - 1 .5 . 5 , 1 .2 .2 ) ; \ fill ( 8 , .8 .8 ) c i rc rc l e ( 1 mm mm ) ; \ en d { t i k z p i c t u r e }
Preserve a natureza Figura 30: Folha \ begin { t i k z p i c t u r e } [ x = 2 p t , y = 2 p t ] \ fill [ g r e e n ] ( 4 5 .9 .9 5 , 4 8 . 6 7 ) . . c o n t r ol ol s ( 4 5 . 9 5 , 4 8 . 6 7 ) a n d ( 4 6 . 45 45 , 1 3 . 0 5 ) ..(34.32,7.12) . . c o nt nt r ol o l s ( 2 2. 2. 0 9 , 1. 1 . 1 5) 5) a nd nd ( 2 .7 .7 6 , 7 .9 .9 ) . . ( 1 2. 2. 0 4 , 27 27 ) . . c o nt nt r ol o l s ( 1 8. 8. 9 , 4 1. 1 . 1 3) 3) a nd nd ( 3 8. 8. 3 3 , 32 32 ) . . ( 4 5. 5. 9 5 , 48 4 8 . 67 67 ) - - c y cl cl e ; \ d r aw aw [ g r ee e e n ! 7 5! 5! b l ac ac k , l i n e w i dt dt h = 2 pt pt ] ( 6 .8 .8 2 , 5 .2 . 2 2 ) . . c o nt n t r ol ol s ( 9 , 5) 5) a nd nd ( 3 5 . 12 12 , 1 4 . 8 5 ) . . ( 4 1 .9 .9 5 , 3 6 . 7 ) ; \ node a t ( 20 2 0 , 0 ) { \ L ar ar g e P r es e s e rv r v e a n a tu t u r ez ez a } ; \ en d { t i k z p i c t u r e }
Veja trˆes es videos no youtube: bezier01, bezier01, bezier02 e drawing android in LaTeX with KTikz. KTikz. Veja tamb´em em o t´opico opico Desenhando no TikZ com imagem de referˆ encia, encia, que ´e uma continua¸ continua¸c˜ caao ˜o deste t´opico. opico.
R´egis
2011
http://latexbr.blogspot.com/
25