# What does the cm-Option in Tikz do?

In a thread someone uses the option "cm" as shown in the following shortened example:

## Code

\documentclass[12pt,tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\pgfmathsetmacro{\mySqrt}{sqrt(3)/2}
\def\r{1}
\def\a{1}
\draw [cm={\r,0,.5*\r,\mySqrt*\r,(0,0)}]
(1+\a,0) coordinate (-corner 0) coordinate (-corner 3)
-- (\a,1) coordinate (-corner 1)
-- (-\a,1) coordinate (-corner 2)
-- cycle;
\end{tikzpicture}
\end{document}


From the thread: Scaling only a portion of a TikZ polygon (@marsupilam)

## Question

What does this option do and what mean the parameters?

• It’s one of the coordinate transformations (see Tikz manual on the p. 379) Commented Mar 31, 2022 at 8:42
• @Celdor Thank you very much! Commented Mar 31, 2022 at 8:45

Sometimes we need to use specific geometric transformations. See pgfmanual, Section 25.3 Coordinate Transformations, page 378 for the commands cm and reset cm:

A bit explanation:

• scale=2 is the same as cm={2, 0, 0, 2, (0,0)}
• xscale=2 is the same as cm={2, 0, 0, 1, (0,0)}
• yscale=3 is the same as cm={1, 0, 0, 3, (0,0)}
• shift={(3,4)} is the same as cm={1, 0, 0, 1, (3,4)}
• xshift=5cm is the same as cm={1, 0, 0, 1, (5,0)}
• yshift=6cm is the same as cm={1, 0, 0, 1, (0,6)}
• xslant=1.5 is the same as cm={1, 0, 1.5, 1, (0,0)}
• yslant=3 is the same as cm={1, 3, 0, 1, (0,0)}

The following is a small self-tutorial ^^

\documentclass[tikz,border=5mm]{standalone}
\usepackage{amsmath}
\begin{document}
\begin{tikzpicture}[very thick]
\draw[gray!20,thin] (-3,-3) grid (3,3);
\draw[->,gray,thin] (-3.5,0)--(3.5,0) node[below right,black]{$x$};
\draw[->,gray,thin] (0,-3.5)--(0,3.5) node[below left,black]{$y$};
\def\mypath{(0,0) rectangle (1,1)}
%\def\mypath{(0,0) circle(1)}
%\def\mypath{(0,0) parabola (2,2)}
%\def\mypath{(0,0) sin (2,1.5)}
%\def\mypath{(0,0) .. controls +(70:2) and +(-100:1) .. (3,2)}

\draw[blue] \mypath;

% [xscale=-3,yscale=-2,shift={(0,-1)}] is the same as cm={-3, 0, 0, -2, (0,-1)}
\draw[cm={-3, 0, 0, -2, (0,-1)},red] \mypath;

% [xslant=1.5] is the same as [cm={1, 0, 1.5, 1, (0,0)}]
\draw[cm={1, 0, 1.5, 1, (0,0)},cyan] \mypath;

\draw[cm={1, 2, 3, -4, (-3,1)},orange] \mypath;

\path (0,4.5) node[align=center]{
\verb|[cm={a, b, c, d, (t_x, t_y)}]|\\[2mm]
$\begin{pmatrix}a&c\\b&d\end{pmatrix} \begin{pmatrix}x\\y\end{pmatrix}+ \begin{pmatrix}t_x\\t_y\end{pmatrix}$
};
\end{tikzpicture}
\end{document}


As @Celdor mentioned, it is just a coordinate transformation.

Having

\draw[cm={a, b, c, d, (t_x, t_y)}] (0,0) -- (1,1) -- (1,0);


every point is transformed by the formula:

where the point is given by x and y.