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

TikZ (Palestra)
Whom takes fun only as fun.
And serious only seriously.
Misunderstood both.
Piet Hein

Defining and Drawing Points

  • Rectangular coordinates: (1,2)
  • Named Points: \coordinate (A) at (1,2)
  • Polar coordinates: (90: 2)
    PS! Default: angles in degrees
  • Convex combination of \(A\) and \(B\): ($(A)!0.t!(B)$): $$P=t A+(1-t)B, \quad t \in \mathbb{R}$$
  • Algebraic expressions: ($0.5*(A)-0.5*(B)$)
TiKZ Listing: Fig.tikz.tex. PDF   PNG   SVG   ZIP*  
%Make TiKZ use radians - default is degrees
\begin{tikzpicture}[trig format=rad]
   %Rectangular coordinates
   \coordinate (A) at (1,0);
  
   %Polar coordinates
   \coordinate (B) at (1.1*pi/2:2);
  
   %Polar coordinates
   \coordinate (C) at (pi/3:2);

   \filldraw (0,0) circle (1pt) node {$O$};

   %Baaaad...
   \draw [cyan] (A) circle (2pt);
   \filldraw [magenta] (C) circle (1pt);
   \filldraw [orange] (B) circle (1pt);

   %Define convex parameter
   \tikzmath{\t=-0.2;};

  
   %Convex combinations
   \draw [orange] ($(A)!\t!(B)$) -- ($(B)!\t!(A)$);

   %Midpoint
   \coordinate (M) at ($(A)!0.5!(B)$);

   %Clean below, draw afterwards
   \filldraw [color=white] (M) circle (2pt);
   \draw [color=gray] (M) circle (2pt);
  
   %Projection of (C) on AB
   \coordinate (P) at ($(A)!(C)!(B)$);
   \filldraw [color=white] (P) circle (2pt);
   \draw [color=blue] (P) circle (2pt);
   
   %Half of (A)-(B)
   \coordinate (Q) at ($0.5*(A)-0.5*(B)$);
   \filldraw [color=white] (Q) circle (2pt);
   \filldraw [color=black] (Q) circle (1pt);
\end{tikzpicture}
Messages:
0 secs.