Mathematical Coding — Trigonometry — Session 5 — Art and Creativity
Session Overview
The class opened with meditation and a discussion of creativity as a bridge between mathematical structure, intuition, and artistic truth. The final coding workshop of the series then explored animated 3D surfaces in Processing, a modular “vortex” artwork, and a trigonometric sketch involving a tangent to a circle.
And so we need to bridge the coldness of pure structural truth with the warmth of heart, and feeling, and creativity, and freedom.
Mathematics as a creative art
Mathematical rigor and artistic intuition were presented as complementary rather than opposed. Music, architecture, geometry, and mathematical coding all combine structure with inspired choices about what a creation should become.
Processing techniques explored
The live coding demonstrated how trigonometry, coordinate systems, and rendering details shape mathematical art.
- Surface meshes: Nested loops sampled a grid, with each corner receiving its own height f(x,y). Increasing the number of divisions produced a smoother surface.
- Coordinates and transformations: Graph units were scaled into pixel space. Translation and rotation order mattered, and the object had to be rotated when the assumed vertical axis differed from Processing’s coordinates.
- Animation: A frameCount division bug repeated each state for 60 frames because of integer division. Converting the calculation to floating-point restored smooth motion.
- Trigonometric camera motion: Sine and cosine moved the camera around the surface, while radial sine functions created rippling forms whose amplitude changed with distance.
- Redrawing frames: Placing background() inside draw() clears the previous frame; otherwise moving elements leave accumulated trails.
- Angles: atan2(y,x) was introduced as a coding-friendly arctangent that identifies angles around the full circle.
Workshop projects
Students developed separate mathematical-art experiments and shared their progress.
- Animated 3D surface: A rotating mesh evolved from a paraboloid into a radial wave surface. Surface normals and smooth lighting were briefly examined, but the automatically generated replacement code was not adopted.
- Modular vortex: A JavaScript and BabylonJS tool connected evenly spaced points using a multiplier and modular arithmetic. Changing the parameters produced flowers, eye-like forms, and cardioid patterns in both 2D and 3D.
- Circle-tangent sketch: The sketch included coordinate axes and a moving point, then began calculating a tangent using cosine and atan2. Translating the origin to the center of the screen was suggested to simplify the remaining coordinate calculations.
Workflow and finished artwork
Use Git locally and GitHub remotely to preserve versions and recover deleted code. Processing frames can be exported with saveFrame() and assembled into a video using FFmpeg; Homebrew was recommended for installing FFmpeg. Finished work could become an animation, a wall print, or a 3D-printed object, and AI coding tools should be used for targeted help without surrendering the overall design or learning process.