Let's break it down:
PGFmath assumee the parameters to sin, cos, etc. to be in degrees, not radians, so we need to convert those either with the deg function or the r postfix operator: sin(deg(x) or sin(x r).
TikZ/PGF/TeX internally is working with pt where 1 cm = 28.45274 pt. So even if we convert the radians to degrees we're totally off.
TikZ/PGF uses various coordinate systems. The most important ones are
- the
canvas coordinate system where we're using actual length: (10mm, -3em)
- the
xyz coordinate system (though, we often use only x and y) where we're using scalar value: (2, 2*pi+3/2).
Both coordinate systems also have a polar version (<angle>:<value>) but these can be converted to the ones with x and y values easily.
How does the xyz cordinate system knows how long a value like 2 or 2*pi+3/2 is on the paper? It uses another transformation layer and the values given to the keys x, y and z. By default, these are x = 1cm (meaning 1 cm in the direction to the right on the canvas) and y = 1m (up).
This is something that PGF provides on its layer.
So we devide the \pgf@x by 1cm and convert that to degrees and we're done?
Not quite. For once, we can access the value of 1cm by using \pgf@xx which we can use to divide \pgf@x by but then we are in the xyz coordinate system. We need to get back to the canvas coordinate system by multiplying the sine with \pgf@xx which brings me to this formula you oughta want to use:
\def\mytransformation{%
\pgfmathsetlength\pgf@x{\pgf@x + 10*\pgf@xx*sin(\pgf@x/\pgf@xx r)}%
}
That is, convert the canvas x value back to its xyz x value, convert that to degrees, take the sine of it and then multiply it back into the canvas coordinate system (and then your factor of 10).
Now, if you use a more complex xyz coordinate system, let's just say x = {(1cm, 1cm)}, i.e. the x axis has an angle of 45° on the paper and the length of √2 both
\pgf@xx (the length of a unit on the x axis in x direction) and
\pgf@xy (the length of a unit on the x axis in y direction)
will be set to 28.45274pt.
(And yes, there's also \pgf@yy, \pgf@yx, \pgf@zx and \pgf@zy.)
I have no clue how your transformation should look like then. (At that point, it's a math problem I believe.)
If you check the examples in the manual about nonlinear transformations you'll notice that it only uses coordinates in the canvas coordinate system. The \polartransformation example even uses
\draw (0pt,0mm) grid [xstep=10pt, ystep=5mm] (90pt, 20mm);
Notice the 90pt! This will be 90° for the quarter circle it'll draw. (Or 3.16314cm, i.e (3.16314, 2) in the xyz coordinate system. Somewhat close to π, but purely by accident – and we were looking for π/2 anyway.)
I've added the plot
\draw[dashed, ultra thick] plot[smooth,samples=100,domain=0:20] ({\x + 10 * sin(\x r)}, \x);
for comparison. Depending on your actual task, this might just be an easier way to draw lines that abide to any(?) transformation.
And if you really want to plot something, use pgfplots.
Code
\documentclass[tikz,border=3mm]{standalone}
\usepgfmodule{nonlineartransformations}
\makeatletter
\def\mytransformation{%
\pgfmathsetlength\pgf@x{\pgf@x + 10*\pgf@xx*sin(\pgf@x/\pgf@xx r)}%
}
\makeatother
\begin{document}
\begin{tikzpicture}[x=.5cm]% for fun
\foreach \x in {-3,...,10}
\path (0:\x*pi) node[below]{$\x\pi$} edge[help lines, very thin] + (up:20) edge + (up:2pt)
++ (0:.5*pi) node[below]{$\pgfmathprint{\x+.5}\pi$} edge[help lines, very thin, dotted] + (up:20) edge + (up:1pt);
\draw[dashed, ultra thick] plot[smooth,samples=100,domain=0:20] ({\x + 10 * sin(\x r)}, \x);
\foreach \sh in {-10,0,10}
\draw[shift=(0:\sh)] (0,0) -- (20,20);
\begin{scope}
\pgftransformnonlinear{\mytransformation}
\draw [thick, red] (0,0) -- (20,20);
\end{scope}
\end{tikzpicture}
\end{document}

x \mapsto (x + sin x), y \mapsto y. – DJP Jul 31 '22 at 00:4610in their MWE, so I'm using that. If you remove the10*from both theplotas well as from the\mytransformationwe're getting this output. – Qrrbrbirlbel Jul 31 '22 at 00:49x \mapsto (x + a * sin x), y \mapsto yso it contains the factor of 10. – Physor Jul 31 '22 at 08:42