Another Integer Triangle Wave
February 10, 2018 by Chris Johnson. Filed under
Deprecated: Creation of dynamic property WP_Term::$cat_ID is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 378
Deprecated: Creation of dynamic property WP_Term::$category_count is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 379
Deprecated: Creation of dynamic property WP_Term::$category_description is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 380
Deprecated: Creation of dynamic property WP_Term::$cat_name is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 381
Deprecated: Creation of dynamic property WP_Term::$category_nicename is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 382
Deprecated: Creation of dynamic property WP_Term::$category_parent is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 383
Deprecated: Creation of dynamic property WP_Term::$cat_ID is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 378
Deprecated: Creation of dynamic property WP_Term::$category_count is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 379
Deprecated: Creation of dynamic property WP_Term::$category_description is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 380
Deprecated: Creation of dynamic property WP_Term::$cat_name is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 381
Deprecated: Creation of dynamic property WP_Term::$category_nicename is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 382
Deprecated: Creation of dynamic property WP_Term::$category_parent is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 383
algorithms, public.
I’ve across another way to generate a triangular wave. So exciting!
Recall from last time that I want to generate a pattern that looks like this:
In this example, the period is 10.
As before, we can generate a sawtooth wave with some help from modulus:
$$y = \textrm{mod}(x, \textrm{period})$$
We can also generate a flipped sawtooth wave by taking the complement of the period:
$$y = \textrm{period} – \textrm{mod}(x, \textrm{period})$$
Let’s superimpose these real quick:
The wave I want is in there. It’s the bottom half of the weave. We can select out the bottom half with the min function:
$$y = \min(\textrm{mod}(x, \textrm{period}), \textrm{period} – \textrm{mod}(x, \textrm{period}))$$
The graph I used to think this through is on Desmos.