How to specify rotation origin in openscad

1

OpenSCAD has rotate function which rotates the body around its origin axis.

Is there a way to specify an arbitrary axis?

For example, this rotates a cylinder around its center:

rotate(a=[90,0,0]) {
  cylinder(h=10,r1=10,r2=10);
}

How to make it rotate around its edge?

Vanuan

Posted 2019-02-03T15:18:45.167

Reputation: 111

Question was closed 2019-02-05T12:29:56.747

2

Found a duplicate on stackooverflow https://stackoverflow.com/questions/45826208/openscad-rotating-around-a-particular-point

– Vanuan – 2019-02-03T17:26:59.667

Answers

2

rotate() always rotates around the origin of the object following it. What you can do is to move your cylinder away from the origin, like this:

rotate(a=[90,0,0]) {
  translate([0,10,0]) cylinder(h=10,r1=10,r2=10);
}

kintel

Posted 2019-02-03T15:18:45.167

Reputation: 141

1

You can use the following module in your code to achieve what you wish:

module myrotate(a, orig) {
    translate(orig)
    rotate(a)
    translate(-orig)
    children();
}

myrotate([0,0,90], [0, 10, 0]) {
    cube([10, 10, 25]);
}

myrotate([0,0,-90], [0, 10, 0]) {
    cube([10, 10, 25]);
}

color([1, 0, 0])
cube([10, 10, 25]);

Cem Kalyoncu

Posted 2019-02-03T15:18:45.167

Reputation: 179