I've created this function (https://www.desmos.com/calculator/3uwpld1lqb):
$$\mathrm{saw}(x, q) = x-\lfloor x \rfloor$$
$$\mathrm{slantedTriangle}(x,q) = \dfrac{|\mathrm{saw}\left(x-q\right)-1+q|}{\{\mathrm{saw}\left(x-q\right)-1+q>0:q,1-q}$$
But don't like that $\mathrm{saw}\left(x-q\right)-1+q$ is repeated, nor do I like the use of a piecewise expression. Are there any tricks that can make it look nicer?
Thanks
Here's an interesting way to plot a slanted triangle wave:
$$ y = 2 \left\lvert x - py - \left\lfloor x - py + \frac12 \right\rfloor \right\rvert. \tag1 $$
When $p = 0$ this produces a symmetric triangle wave. If you let $-\frac12 \leq p \leq \frac12$ you can get the same kinds of plots that you get with $\mathrm{slantedTriangle}(x,q)$ with $0 \leq q \leq 1,$ except that at $p = \pm\frac12,$ Equation $(1)$ plots vertical line segments connecting the tops and bottoms of the diagonal segments, whereas at $q = 0$ and $q = 1$, $\mathrm{slantedTriangle}(x,q)$ produces only the diagonal segments.
Moreover, if you let $p$ range over all real numbers, you can get some very slanted triangles which cannot be plotted by setting $y$ to a function of $x.$
The ideas behind this are first of all that you can get a sawtooth function from $y = x - \lfloor x \rfloor.$ But if you generalize this to $$y = x - \lfloor x + s \rfloor,$$ the diagonal segments of the function are shifted down and to the left by $s$ horizontal units and $s$ vertical units. If you set $s = \frac12$ the segments are exactly half above the $x$ axis and half below; take the absolute value and you get a triangle wave. Multiply by $2$ so that the peaks of the triangles reach the line $y = 1.$ That is, the symmetric case of your triangle wave can be plotted by
$$ y = 2 \left\lvert x - \left\lfloor x + \frac12 \right\rfloor \right\rvert. $$
Now to get the "slant", we can apply a shear transformation of the plane that leaves the $x$ axis fixed: $(x,y) \to (x + py, y).$ In order to apply this transformation to the graph, we apply the inverse transformation to the variables of the graph's equation: $(x,y) \to (x - py, y).$
That is, replace $x$ by $x - py$ in the equation. This shifts each point of the graph $py$ units to the right (that is, the amount of the shift depends on the height above the $y$ axis), for the same reason that replacing $x$ by $x - b$ in the equation of a graph shifts the entire graph $b$ units to the right.