**“Coding Druid”** series is my **horizontal programming** practice notes, each part around a topic like mathematical, physics, electronic, graphics, sound, etc., implemented in several programming languages.

## Mathematics

In the principle of not digging holes for yourself, I start from a (maybe) simple theory, the trigonometric function of junior high school mathematics.

## Trigonometric function

In mathematics, the trigonometric functions (also called circular functions, angle functions or goniometric functions) are real functions which relate an angle of a right-angled triangle to ratios of two side lengths.

— from wikipediaThey are among the simplest periodic functions, and as such are also widely used for studying periodic phenomena, through Fourier analysis.

The most familiar trigonometric functions are the sine, the cosine, and the tangent.

Note that the **blackened parts**, sound and visual programming are mostly related to them.

**Define a trigonometric function with a unit circle**:

**Cartesian coordinate system sin(x) and cos(x) function images**:

**Get together to understand**:

## MaxMSP implementation of trigonometric function visualization

Max has a lot of functions related to trigonometric function. It can be said that the entire MSP is based on this.

But in this demo I use Max Jitter to visualize trigonometric function, and does not use MSP.

*Max has a lot of subsets features, the most famous of which is the sound-related MSP, and the graphic and image is Jitter.In fact, the official name is now Max, but the early name of MaxMSP is too representative, and the title of this article also uses MaxMSP.*

At first I felt it would be a very simple stuff. But It took a few hours in total. I feel that I learn Max just like water in drops, while like spring water when forgetting.

The implemented patch is following:

Some Max clips I referenced a great video tutorial series:

Amazing Max/Msp Tutorial

https://www.youtube.com/watch?v=HN8nQ_KtG6k

The general idea is to use `jit.gen`

to operate `jit.matrix`

, the trigonometric logic is written in `jit.gen`

, and then the last transformed `matrix`

is drawn with `jit.mesh`

.

In short, to put an elephant into a refrigerator, there are only three steps: open the door, put it, and close the door! LOL~

**Final Effect**:

## Talk is cheap. Show me the ~~money~~ code!

This demo and the “Coding Druid” series are **open source**:

https://github.com/avantcontra/coding-druid

You can find more resources in my Patreon. Your encouragement is my driving force!

https://www.patreon.com/avantcontra

Cheers~

Contra

Fb/Tw/Ins/Github: @avantcontra

Website: floatbug.com

## 7 comments