|
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
|
|
Como libertar um povo que preza seus correntes?
Niculau Maquiavel.
|
Triangle Code>
\tikzstyle{circum} = []
\tikzstyle{bari} = []
\tikzstyle{ortho} = []
\tikzstyle{incenter} = []
\tikzstyle{mediatriz} = [circum,dotted,color=orange]
\tikzstyle{median} = [bari,dotted,color=red]
\tikzstyle{height} = [ortho,dotted,color=blue]
\tikzstyle{bisectriz} = [incenter,dotted,color=green]
% \DrawPoint{P}{Pname}{pos}
\newcommand{\DrawPoint}[3]
{
\filldraw #1 circle(1pt) node[#3] {$#2$};
}
% \GetVector{P1}{P2}.
% Store in (V)
\newcommand{\GetVector}[2]
{
\coordinate (V) at ($#2-#1$);
}
% \DotProduct{vv}{ww}
% Store in \DOT
\newcommand{\DotProduct}[2]
{
\gettikzxy{#1}{\xtmp}{\ytmp};
\gettikzxy{#2}{\xxtmp}{\yytmp};
\tikzmath{\DOT=sqrt(\xtmp*\xxtmp+\ytmp*\yytmp);};
}
% \SqLength{vv}{ww}
% Store in \DOT
\newcommand{\SqLength}[2]
{
\DotProduct{#1}{#1};
}
% \Determinant{vv}{ww}
% Store in \DET
\newcommand{\Determinant}[2]
{
\gettikzxy{#1}{\xtmp}{\ytmp};
\gettikzxy{#2}{\xxtmp}{\yytmp};
\tikzmath{\DET=\xtmp*\yytmp-\xxtmp*\ytmp;};
}
% \Length{vv{ww}
% Store in \LEN
\newcommand{\Length}[1]
{
\DotProduct{#1}{#1};
\tikzmath{\LEN=sqrt(\DOT);};
}
% \GetPerpendicular{P}{v}
% Store in (N)
\newcommand{\GetPerpendicular}[1]
{
%Get V coords (in pt)
\gettikzxy{#1}{\xtmp}{\ytmp};
\coordinate (N) at (-\ytmp,\xtmp);
}
% \GetNormal{P}{v}
% Store in (N)
\newcommand{\GetNormal}[1]
{
\Length{#1};
\tikzmath{\LEN=sqrt(\DOT);};
%Get V coords (in pt)
\gettikzxy{#1}{\xtmp}{\ytmp};
%Calculaty len
\tikzmath{\LEN=sqrt(\xtmp*\xtmp+\ytmp*\ytmp);};
%Normalize
\tikzmath{\xtmp=1/\LEN*\xtmp;};
\tikzmath{\ytmp=1/\LEN*\ytmp;};
\coordinate (N) at (-\ytmp,\xtmp);
}
% \DrawConvex{P}{Q}{t}
\newcommand{\DrawConvex}[4]
{
\draw[#4] ($#1!#3!#2$) -- ($#2!#3!#1$);
}
% \DrawTriangleHeight{A}{B}{C}
\newcommand{\DrawTriangleHeightOld}[3]
{
%Projection on point #1 on #2 and #3
\coordinate (P) at ($#2!#1!#3$);
\DrawPoint{(P)}{P}{below};
%Orthogonal Complement of point #1
\coordinate (N) at ($(P)-#1$);
\draw[-latex] (P) -- +(N);
}
% \DrawTriangle{A}{B}{C}
\newcommand{\DrawTriangle}[3]
{
\draw
#1 circle(1pt)
--
#2 circle(1pt)
--
#3 circle(1pt)
--
#1;
}
% \DrawMidPoint{A}{B}{title}{sty}
\newcommand{\DrawMidPoint}[4]
{
\filldraw
($0.5*#1+0.5*#2$)
circle(1pt)
node[#4]
{\scriptsize{#3}};
}
% \DrawTriangleMidPoints{A}{B}{C}{title}{sty}
\newcommand{\DrawTriangleMidPoints}[3]
{
\DrawMidPoint{#2}{#3}
{$\underline{m}_1$}
{above};
\DrawMidPoint{#3}{#1}
{$\underline{m}_2$}
{left};
\DrawMidPoint{#1}{#2}
{$\underline{m}_3$}
{below};
}
% \DrawTriangleMedian{A}{B}{C}{linesty}
\newcommand{\DrawTriangleMedian}[3]
{
\draw[median]
($1/3*#1+1/3*#2+1/3*#3$)
--
+($0.5*#1 + 0.5*#2 -1*#3$);
\draw[median]
($1/3*#1+1/3*#2+1/3*#3$)
--
+($-0.5*#1 - 0.5*#2 + #3$);
}
% \DrawTriangleMedians{A}{B}{C}{sty}
\newcommand{\DrawTriangleMedians}[3]
{
\DrawTriangleMedian{#1}{#2}{#3}{1};
\DrawTriangleMedian{#2}{#3}{#1}{2};
\DrawTriangleMedian{#3}{#1}{#2}{3};
}
% \DrawTriangleBaricenter{A}{B}{C}{sty}
\newcommand{\DrawTriangleBaricenter}[3]
{
\filldraw[bari]
($1/3*#1+1/3*#2+1/3*#3$)
circle(1pt) node[left] {B};
}
% \DrawMediatriz{A}{B}{C}{sty}
\newcommand{\DrawTriangleMediatriz}[4]
{
\coordinate (M) at ($#1!0.5!#2$);
\coordinate (v) at ($#2 - #1$);
\GetPerpendicular{(v)};
\draw[mediatriz]
($(M)+(N)$)
--
(M)
--
($(M)-0.3*(N)$)
node {$#4$};
}
% \DrawMediatrizes{A}{B}{C}{sty}
\newcommand{\DrawTriangleMediatrizes}[3]
{
\DrawTriangleMediatriz{#1}{#2}{#3}{1};
\DrawTriangleMediatriz{#2}{#3}{#1}{2};
\DrawTriangleMediatriz{#3}{#1}{#2}{3};
}
% \DrawCircumCenter{A}{B}{C}{sty}
\newcommand{\DrawTriangleCircumCenter}[3]
{
%Translate so first point in (0,0)
\coordinate (V) at ($#2 - #1$);
\coordinate (W) at ($#3 - #1$);
\gettikzxy{(V)}{\vx}{\vy};
\gettikzxy{(W)}{\wx}{\wy};
%Lengths
\tikzmath{\rv=\vx*\vx+\vy*\vy;};
\tikzmath{\rw=\wx*\wx+\wy*\wy;};
%Determinant
\tikzmath{\deter=\vx*\wy-\vy*\wx;};
%Circum center
\tikzmath{\x=\wy*\rv-\vy*\rw;};
\tikzmath{\y=\vx*\rw-\wx*\rv;};
\tikzmath{\x=0.5*\x/\deter;};
\tikzmath{\y=0.5*\y/\deter;};
\coordinate (Circum) at (\x,\y);
\coordinate (Circum) at ($(Circum)+#1$);
\filldraw[circum] (Circum) circle(1pt) node[right] {$C$};
\tikzmath{\r=\x*\x+\y*\y;};
\tikzmath{\r=sqrt(\r);};
\draw[circum,very thin,dotted] (Circum) circle(\r);
}
% \DrawHeight{A}{B}{C}{sty}{txt}
\newcommand{\DrawTriangleHeight}[4]
{
\coordinate (v) at ($#3 - #2$);
\GetPerpendicular{(v)};
\coordinate (M) at ($#2!#1!#3$);
\draw[height,name path=height#4]
($(M)+(N)$)
--
(M)
--
($(M)-(N)$)
node {$#4$};
}
% \DrawTriangleHeights{A}{B}{C}{sty}
\newcommand{\DrawTriangleHeights}[4]
{
\DrawTriangleHeight{#1}{#2}{#3}{1};
\DrawTriangleHeight{#2}{#3}{#1}{2};
\DrawTriangleHeight{#3}{#1}{#2}{3};
\path [name intersections={of=height1 and height2,by=C}];
\filldraw[ortho] (C) circle(1pt) node[above] {O};
}
% \DrawTriangleBisectriz{A}{B}{C}{sty}{txt}
\newcommand{\DrawTriangleBisectriz}[4]
{
\coordinate (v) at ($#2 - #1$);
\coordinate (M) at ($#3 + (v)$);
\filldraw (M) circle(1pt);
\draw[bisectriz,name path=bisectriz#4]
#1
--
(M)
node {$#4$};
}
% \DrawTriangleBisectrizes{A}{B}{C}{sty}
\newcommand{\DrawTriangleBisectrizes}[3]
{
\DrawTriangleBisectriz{#1}{#2}{#3}{1};
\DrawTriangleBisectriz{#2}{#3}{#1}{2};
\DrawTriangleBisectriz{#3}{#1}{#2}{3};
\path [name intersections={of=bisectriz1 and bisectriz2,by=C}];
\filldraw[incenter] (C) circle(1pt) node[below] {I};
}
|
|
Messages:
0 secs.
|