Étape 24 : continous mesh tournante 90deg chaque couche
Cela montre un maillage de traçage point en permanence dans un X, plan Y.
Le maillage est inversée 90deg après que chaque couche est tracée.
Ceci peut être utilisé pour la sortie X, Y directions pour les moteurs pas à pas.
Commande d’axes Z peut être ajouté à cela.
Traitement / / /
/**
* Point se déplace en arrière sur l’écran - inclut le mouvement dans la direction X et Y
Se répète encore et encore, rotation 90 ° chaque fois qu’une couche est terminée
prend des mesures impaires au début
utilise les différentes variables pour indiquer que c’est en cours
(et parce que j’ai oublié ce que j’utilisais les variables)
*/
res int = 50 ; résolution d’impression
int a = 10 ;
int b = 10 ;
int dir_a = 1 ;
int dir_b = 1 ;
int step_a = 1 ;
int step_b = 0 ;
int old_step_a = 1 ;
int old_step_b = 0 ;
int old_dir_a = 1 ;
int old_dir_b = 0 ;
int dir_switch = 0 ;
int old_dir_switch = 0 ;
int old_a = 0 ;
int old_b = 0 ;
int next_b = res ;
int next_a = res ;
void setup()
{
taille (200, 200) ;
Stroke(255) ;
Background(50) ;
}
void draw()
{
Background(50) ;
Si ((< 10 || un > hauteur - 10) & & old_step_b == 0) {}
dir_a = -1 * dir_a ;
next_b = b + res ;
dir_switch = 1 ;
}
Si ((old_dir_switch! = dir_switch) & & b < next_b) {}
step_a = 0 ;
step_b = 1 ;
dir_switch = 0 ;
}
Si (b > next_b) {}
step_a = 1 ;
step_b = 0 ;
next_b = b + res ;
dir_switch = 0 ;
}
Si ((b < 10 || b > largeur - 10) & & old_step_a == 0) {}
dir_b = -1 * dir_b ;
next_a = un + res ;
dir_switch = 1 ;
}
Si ((old_dir_switch! = dir_switch) & & un < next_a) {}
step_b = 0 ;
step_a = 1 ;
dir_switch = 0 ;
}
Si (un > next_a) {}
step_b = 1 ;
step_a = 0 ;
next_a = un + res ;
dir_switch = 0 ;
}
calculer la postion
un = un + dir_a * step_a ;
b = b + dir_b * step_b ;
afficher le point
point(b, a) ; Point de syntaxe (x1, y1)
stocker des valeurs comme vieux pour comparaison
old_a = a ;
old_b = b ;
old_step_a = step_a ;
old_step_b = step_b ;
old_dir_a = dir_a ;
old_dir_b = dir_b ;
old_dir_switch = old_dir_switch + dir_switch ;
Print(b) ;
Print(',') ;
println(a) ;
}