Skip to content

Instantly share code, notes, and snippets.

@thehans
Created June 4, 2021 23:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thehans/ca0ec0516c0b1b4af8ce2f580ef5ffc7 to your computer and use it in GitHub Desktop.
Save thehans/ca0ec0516c0b1b4af8ce2f580ef5ffc7 to your computer and use it in GitHub Desktop.
Different ways of mirroring in OpenSCAD
independent = false; // Note: Independent mirroring of 2 axes is actually a rotation
fix111 = false; // Only relevant if independent=false
module thing(i,j,k) {
translate([2,2,2]) difference() {
cube(2,center=true);
linear_extrude(convexity=10)
text(text=str("M",i,j,k),size=0.5,valign="center",halign="center");
}
}
if (independent) {
for(i=[0,1],j=[0,1],k=[0,1])
mirror([i,0,0]) mirror([0,j,0]) mirror([0,0,k]) thing(i,j,k);
} else {
if (fix111) {
for(i=[0,1],j=[0,1],k=[0:1:2-i-j])
mirror([i,j,k]) thing(i,j,k);
scale(-1) thing(1,1,1); // mirror through origin
} else {
for(i=[0,1],j=[0,1],k=[0,1])
mirror([i,j,k]) thing(i,j,k);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment