Slide 1

Slide 1 text

Visually experience the beauty of mathematics with p5.js 19 Nov, 2023 JSConf JP @kkeeth @kuwahara_jsri @kkeeth

Slide 2

Slide 2 text

Who am I

Slide 3

Slide 3 text

3

Slide 4

Slide 4 text

4

Slide 5

Slide 5 text

5 outputs

Slide 6

Slide 6 text

npmjs.com/~kkeeth

Slide 7

Slide 7 text

Let’s start 😆

Slide 8

Slide 8 text

My Math History

Slide 9

Slide 9 text

Undergraduate: Riemann's zeta function (Part of Riemann hypothesis) Graduate Student: Knot Theory (Part of Volume conjecture) My Math History

Slide 10

Slide 10 text

A Million Dollars at Stake. Seven of the most dif f icult problems in mathematics One problem (the Poincaré Conjecture) was solved (proved) by Perelman Aside: “millennium prize problems”

Slide 11

Slide 11 text

Introduction to p5.js

Slide 12

Slide 12 text

Do you know p5.js ? 😁

Slide 13

Slide 13 text

URL: https://p5js.org/

Slide 14

Slide 14 text

👉 About p5.js

Slide 15

Slide 15 text

Processing p5.js Programming Language Java / (JavaScript) JavaScript Operating Environment mainly PC Web Browser Performance Normal little slow

Slide 16

Slide 16 text

URL: https://editor.p5js.org/

Slide 17

Slide 17 text

setup This function is called once. It's used to de fi ne initial environment properties. draw Called directly after setup, continuously executes the lines of code contained inside its block until the program is stopped.

Slide 18

Slide 18 text

setup This function is called once. It's used to de fi ne initial environment properties. draw Called directly after setup, continuously executes the lines of code contained inside its block until the program is stopped.

Slide 19

Slide 19 text

https://github.com/processing/p5.js/blob/v1.7.0/src/core/main.js#L418

Slide 20

Slide 20 text

Experience the beauty of mathematics with some p5.js examples

Slide 21

Slide 21 text

Equation of a circle

Slide 22

Slide 22 text

Equation of a circle x2 + y2 = r2 O θ y x r P(x, y)

Slide 23

Slide 23 text

Equation of a circle x2 + y2 = r2 O θ y x r P(x, y) x = ? y = ?

Slide 24

Slide 24 text

Polar Coordinate System O θ r x = r cos(θ) y = r sin(θ) (r ≥ 0) P(r, θ)

Slide 25

Slide 25 text

No content

Slide 26

Slide 26 text

Trigonometric functions (circular functions)

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

URL: https://sites.google.com/site/cinderellajapan/huanocg/huano-qu-xian

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

Quiz 💁 How does the following code behave?

Slide 33

Slide 33 text

core part of this code

Slide 34

Slide 34 text

Execution result

Slide 35

Slide 35 text

Execution result Fibonacci sequence famous for sun fl ower seeds

Slide 36

Slide 36 text

Fibonacci sequence 1, 1, 2, 3, 5, 8, 13, 21, 34... 1 1 , 2 1 , 3 2 , 5 3 , 8 5 , 13 8 , 21 13 , 34 21 . . . 1,2,1.5,1.66,1.6,1.625,1.615,...1.619... → 1.61803

Slide 37

Slide 37 text

Fibonacci sequence 1, 1, 2, 3, 5, 8, 13, 21, 34... 1 1 , 2 1 , 3 2 , 5 3 , 8 5 , 13 8 , 21 13 , 34 21 . . . 1,2,1.5,1.66,1.6,1.625,1.615,...1.619... → 1.61803

Slide 38

Slide 38 text

Fibonacci sequence 1, 1, 2, 3, 5, 8, 13, 21, 34... 1 1 , 2 1 , 3 2 , 5 3 , 8 5 , 13 8 , 21 13 , 34 21 . . . 1,2,1.5,1.66,1.6,1.625,1.615,...1.619... → 1.61803 Golden ratio ϕ = 1 + 5 2

Slide 39

Slide 39 text

Quiz 💁 What was used to draw the next image?

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

Lemniscate orthogonal coordinate system (x2 + y2)2 − 2a2(x2 − y2) = 0 polar coordinate system r2 = 2a2 cos 2θ

Slide 42

Slide 42 text

Lemniscate x = a cos(t) 1 + sin2(t) y = a sin(t)cos(t) 1 + sin2(t)

Slide 43

Slide 43 text

Quiz 💁 What was used to draw the next images?

Slide 44

Slide 44 text

No content

Slide 45

Slide 45 text

Euclidean Algorithm

Slide 46

Slide 46 text

Euclidean Algorithm a = bq + r (a ≥ b) gcd(a, b) = gcd(b, r)

Slide 47

Slide 47 text

Rose Curve

Slide 48

Slide 48 text

No content

Slide 49

Slide 49 text

r = sin(θ n d )

Slide 50

Slide 50 text

https://zenn.dev/kkeeth/articles/rose-curve-variations

Slide 51

Slide 51 text

Flow FieldɾVector Field

Slide 52

Slide 52 text

No content

Slide 53

Slide 53 text

No content

Slide 54

Slide 54 text

Ken Perlin’s Perlin Noise Pseudo Vector Field Generation

Slide 55

Slide 55 text

Digression

Slide 56

Slide 56 text

🤔 Is there anything that combines programming, mathematics and art ?

Slide 57

Slide 57 text

✕ Mathematics JavaScript Art works

Slide 58

Slide 58 text

✕ Mathematics JavaScript Art works Creative Coding Generative Art

Slide 59

Slide 59 text

URL:https://www.pinterest.jp/pin/190980840435280107/ URL: https://www.pinterest.jp/pin/129267451795680561/

Slide 60

Slide 60 text

URL: https://www.pinterest.jp/pin/353180795787592200/ URL: https://twitter.com/t_ritoco/status/1461470820274819072/photo/3

Slide 61

Slide 61 text

Have fun with p5.js 😆

Slide 62

Slide 62 text

References p5.js Get Started • https://p5js.org/get-started/ δΣωϥςΟϒɾΞʔτɹProcessingʹΑΔ࣮ફΨΠυ • https://www.amazon.co.jp/dp/4861009634 Pinterst Search(generativeart) • https://onl.tw/2bhH4ZD Openprocessing • https://openprocessing.org/user/299354?o=13&view=sketches 𝕏 hash tag ”#ͭͿ΍͖Processing” • https://x.com/search?q=ͭͿ΍͖Processing&src=typeahead_click&f=live

Slide 63

Slide 63 text

No content