math+art
SubscribeBlogAbout

Dynamic Visualizations

April 20, 2020

The site now has the capability to include p5.js sketches into blog posts. The framework enables math+art to provide visualizations of mathematical concepts in fun ways. For example, let's take a look at a simple example of sinusoidal motion.

This square's position oscillates via a sinusoidal function of time. Given the height hh of its container, the square's xx position behaves as

xs(t)=(h/16)sin(t).x_s(t) = (h / 16) \sin(t).

p5.js provides a nice interface to bring this equation to life. Similarly, we can visualize circular motion — and while we're at it, let's reduce the velocity too.

That one's coordinate positions are

xc(t)=(h/4)sin(t/4)yc(t)=(h/4)cos(t/4).\begin{aligned} x_c(t) &= (h / 4) \sin(t / 4)\\ y_c(t) &= (h / 4) \cos(t / 4). \end{aligned}

Finally, we can combine the two motions, i.e., x(t)=xs(t)+xc(t)x(t) = x_s(t) + x_c(t) and y(t)=yc(t)y(t) = y_c(t).

While these examples just scratch the surface of what's possible with p5.js sketches, I look forward to including more advanced and interesting visualizations in future posts.

Receive emails about new posts and subscriber-exclusive content.

Copyright © 2022 Robert Adkins. All rights reserved.