Skip to content

Instantly share code, notes, and snippets.

@yejianfengblue
Created June 11, 2022 02:21
Show Gist options
  • Save yejianfengblue/bd8a752631d8231121b3003fe8d570ec to your computer and use it in GitHub Desktop.
Save yejianfengblue/bd8a752631d8231121b3003fe8d570ec to your computer and use it in GitHub Desktop.
rotate 45 degree with center point (0, -50) in openscad
// the red cube is the original object I'm going to transform
color("red")
cube([10, 10, 10], center = true);
// my goal is, in work plane XY, rotate the cube in the path of a circle whose center point is (0, -50) and radius is 50mm, rotate angle is 45 degree clockwise
// openscad rotate function always rotate with world coordinate center point (0, 0, 0)
// so step 1, move the cube to (0, 50, 0) by translate 50mm in y axis, the result is the green cube
color("green")
translate([0, 50, 0]) {
cube([10, 10, 10], center = true);
}
// step 2, rotate 45 degree
color("blue")
rotate([0, 0, -45]) {
translate([0, 50, 0]) {
cube([10, 10, 10], center = true);
}
}
// step 3, translate -50mm in y axis, the result is the yellow cube
color("yellow")
translate([0, -50, 0]) {
rotate([0, 0, -45]) {
translate([0, 50, 0]) {
cube([10, 10, 10], center = true);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment