Date:2023-10-30
Chladni Figure Code|クラドニ図形・コード with Processing
本記事では、クラドニ・プレート(クラドニ図形)をデジタル上で表現するため、その数式とProcessingを使用した制作方法を紹介します。最も古典的な音の視覚化表現方法。音が生み出す様々な幾何学模様を楽しむことができます。

Chladni図形(Chladni figures)は、18世紀にドイツの物理学者であるエルンスト・フロイント・クラドニ(Ernst Florens Friedrich Chladni)によって考案されました。
これら図形の制作は、固定した平面プレート上に細かい粒子を散布し、特定の周波数によって振動させることで美しい幾何学的パターンが浮かび上がります。
Chladni図形の研究は、楽器の音響設計や共鳴の理解、振動現象の視覚化、音響工学、および物理学の教育など、さまざまな分野で利用されています。
Case : barbe_generative_diary
数式:クラドニプレート(2D)
クラドニプレート実験は、プレートの端または中央点で固定し、バイオリンの弓や、スピーカーにてプレートを振動させます。プレート常に細かい砂をふりかけて実験を行うことで、表面の振動していない部分(節)に粒子が集まることで図形が生成されます。

中心に拘束された正方形のクラドニプレート (辺の長さ L) 上の定在波の零点の方程式は次のようになります。
cos(n π x / L) cos(m π y / L) – cos(m π x / L) cos(n π y / L) = 0
n, m (正の整数) = プレート上の節数
L = 辺の長さ、x = X軸の位置、y = Y軸の位置
※ n = m の場合、表の下半分は上半分、つまり (n1,m2) = (n2,m1) とイコールになることに注意してください。

Processing コード:クラドニプレート(2D)
下記、Processingコードを用いたクラドニプレート2D。

int xCount = 120;
int yCount = 120;
float n = 5;
float m = 3;
float randNM = 20;
Particle[] myParticles = new Particle[xCount*yCount];
void setup() {
size(1200,1200,P2D);
background(0);
smooth();
initParticle();
shuffle();
}
void draw() {
translate(width / 2, height / 2);
scale(1.0 * width/2, 1.0 * height/2);
background(0);
noFill();
stroke(255,180);
strokeWeight(0.003);
for (int i = 0; i < myParticles.length; i++) {
myParticles[i].update();
myParticles[i].display();
}
}
void shuffle() {
n = floor(random(randNM));
m = floor(random(randNM));
while (m == n) {
m = floor(random(randNM));
}
}
void initParticle() {
int i = 0;
for (int y = 0; y < yCount; y++) {
for (int x = 0; x < xCount; x++) {
myParticles[i] = new Particle();
i++;
}
}
}
class Particle extends PVector {
float x,y;
float speed;
Particle() {
x = random(-1, 1);
y = random(-1, 1);
speed = 0.035;
}
void update() {
float vibrationmax = 0.003;
float vibrationX = random(-vibrationmax, vibrationmax);
float vibrationY = random(-vibrationmax, vibrationmax);
float amount = chladni(x, y);
float randomNum = random(-0.5,1.0);
if (amount >= 0) {
if (chladni(x + vibrationmax, y) >= amount) {
x = constrain(x - randomNum * amount * speed + vibrationX, -1, 1);
} else {
x = constrain(x + randomNum * amount * speed + vibrationX, -1, 1);
}
if (chladni(x, y + vibrationmax) >= amount) {
y = constrain(y - randomNum * amount * speed + vibrationY, -1, 1);
} else {
y = constrain(y + randomNum * amount * speed + vibrationY, -1, 1);
}
} else {
if (chladni(x + vibrationmax, y) <= amount) {
x = constrain(x + randomNum * amount * speed + vibrationX, -1, 1);
} else {
x = constrain(x - randomNum * amount * speed + vibrationX, -1, 1);
}
if (chladni(x, y + vibrationmax) <= amount) {
y = constrain(y + randomNum * amount * speed + vibrationY, -1, 1);
} else {
y = constrain(y - randomNum * amount * speed + vibrationY, -1, 1);
}
}
}
float chladni(float x, float y) {
float L = 2;
return cos(n * PI * x / L) * cos(m * PI * y / L) - cos(m * PI * x / L) * cos(n * PI * y / L);
}
void display() {
point(x, y);
}
}
参考:Chladni plate interference surfaces
http://paulbourke.net/geometry/chladni/
Recommended Book for Processing

Generative Design / Processingで切り拓く、デザインの新たな地平
-Harmut Bohnacker, Benedikt Groß, Julia Laub
2012年に出版されたGenerative Designの日本語版、プログラミングによる視覚表現の解説本。Generative Designのオリジナルライブラリを利用することで、ビギナーにも優しいプログラムコードと解説でジェネラティブデザインが楽しめます。たくさんの美しい作品例と解説により、インスピレーションやリソースとして役立つだけでなく、プログラマーでない人にとっても新しいデザイン体験を与えてくれます。
ーーーーー
► 『Generative Design / Processingで切り拓く、デザインの新たな地平』(Harmut Bohnacker, Benedikt Groß, Julia Laub)
初版/ 2018.1.24
ページ数/495ページ
出版社/ビー・エヌ・エヌ新社
言語/日本語
ーーーーー