Outils pour utilisateurs

Outils du site


figure_de_lichtenberg

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
Prochaine révisionLes deux révisions suivantes
figure_de_lichtenberg [2019/11/24 09:11] – [Processing 3D] Mushussufigure_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(), 0, limite));
 +  }
 +
 +  void afficher(int r) {
 +    noStroke();
 +    int teinte = (int)map(rang, 0, r, 255, 10);
 +    fill(teinte);
 +    pushMatrix();
 +    translate(position.x, position.y, position.z);
 +    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;
 +}
 +</code>
 +
 +Pour la partie OpenSACD de l'exportation .stl :
 +<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