<p>You can use the following module in your code to achieve what you wish:</p>

<pre><code>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]);
</code></pre>

CC BY-SA 4.0
2019-02-03T16:42:46.690Z
2019-02-03T16:42:46.690Z
Cem Kalyoncu
<p><code>rotate()</code> always rotates around the origin of the object following it.
What you can do is to move your cylinder <em>away</em> from the origin, like this:</p>

<pre><code>rotate(a=[90,0,0]) {
  translate([0,10,0]) cylinder(h=10,r1=10,r2=10);
}
</code></pre>

CC BY-SA 4.0
2019-02-03T16:27:21.453Z
2019-02-03T16:27:21.453Z
kintel
<p>OpenSCAD has <code>rotate</code> function which rotates the body around its origin axis.</p>

<p>Is there a way to specify an arbitrary axis?</p>

<p>For example, this rotates a cylinder around its center:</p>

<pre><code>rotate(a=[90,0,0]) {
  cylinder(h=10,r1=10,r2=10);
}
</code></pre>

<p>How to make it rotate around its edge?</p>

CC BY-SA 4.0
2019-02-03T17:26:59.667Z
Found a duplicate on stackooverflow https://stackoverflow.com/questions/45826208/openscad-rotating-around-a-particular-point
Vanuan
<openscad>
How to specify rotation origin in openscad
Vanuan
# How to specify rotation origin in openscad

(Asked by: username_0 on 2019-02-03)

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?

**Tags:** openscad

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

---

## 2 answers

### Answer by username_1 on 2019-02-03. Score: 2

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]);

```


---

### Answer by username_2 on 2019-02-03. Score: 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);
}

```


---

