figure_de_lichtenberg
Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédenteProchaine révisionLes deux révisions suivantes | ||
figure_de_lichtenberg [2019/11/24 09:11] – [Processing 3D] Mushussu | figure_de_lichtenberg [2019/11/24 09:13] – [Processing 3D] Mushussu | ||
---|---|---|---|
Ligne 149: | Ligne 149: | ||
==== Processing 3D ==== | ==== Processing 3D ==== | ||
+ | |||
+ | Voici le code avec exportation .png et .stl : | ||
<code java> | <code java> | ||
import java.io.*; | import java.io.*; | ||
Ligne 266: | Ligne 268: | ||
catch (IOException e) { | catch (IOException e) { | ||
e.printStackTrace(); | e.printStackTrace(); | ||
+ | } | ||
+ | } | ||
+ | |||
+ | class Marcheur { | ||
+ | PVector position; | ||
+ | Marcheur parent; | ||
+ | float rayon; | ||
+ | int rang; | ||
+ | int limite; | ||
+ | |||
+ | Marcheur(int l) { | ||
+ | limite = l; | ||
+ | position = pourtour(limite); | ||
+ | rayon = 15; | ||
+ | rang = 0; | ||
+ | } | ||
+ | |||
+ | Marcheur(int x, int y, int z, int l) { | ||
+ | limite = l; | ||
+ | position = new PVector(x, y, z); | ||
+ | rayon = 30; | ||
+ | rang = 1; | ||
+ | } | ||
+ | |||
+ | void rafraichir() { | ||
+ | PVector vitesse = PVector.random3D().setMag(30); | ||
+ | position.add(vitesse); | ||
+ | position.setMag(constrain(position.mag(), | ||
+ | } | ||
+ | |||
+ | void afficher(int r) { | ||
+ | noStroke(); | ||
+ | int teinte = (int)map(rang, | ||
+ | fill(teinte); | ||
+ | pushMatrix(); | ||
+ | translate(position.x, | ||
+ | sphere( 2 * rayon); | ||
+ | popMatrix(); | ||
+ | } | ||
+ | } | ||
+ | |||
+ | PVector pourtour(int l) { | ||
+ | PVector v = PVector.random3D().setMag(l); | ||
+ | v.z = abs(v.z); | ||
+ | return v; | ||
+ | } | ||
+ | |||
+ | float dist3DSq(PVector a, PVector b) { | ||
+ | float dx = b.x - a.x; | ||
+ | float dy = b.y - a.y; | ||
+ | float dz = b.z - a.z; | ||
+ | return dx * dx + dy * dy + dz * dz; | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Pour la partie OpenSACD de l' | ||
+ | <code c> | ||
+ | $fn = 15; | ||
+ | |||
+ | u = [[[[10, 10, 10], 30], [[30, 20, 40], 20]], [[[30, 20, 40], 20], [[60, 30, 45], 10]]]; | ||
+ | |||
+ | for (i = [0:len(u) - 1]) { | ||
+ | element(u[i]); | ||
+ | } | ||
+ | |||
+ | module element(e) { | ||
+ | a = e[0]; | ||
+ | b = e[1]; | ||
+ | hull() { | ||
+ | translate(a[0]) sphere(d = a[1]); | ||
+ | translate(b[0]) sphere(d = b[1]); | ||
} | } | ||
} | } |
figure_de_lichtenberg.txt · Dernière modification : 2021/04/21 10:48 de Mushussu