# Rotate all Ipoints (iGeo library)

**URL:** <https://discourse.processing.org/t/rotate-all-ipoints-igeo-library/28950>\
**Category:** Libraries\
**Created:** [March 29, 2021, 3:32pm UTC](https://discourse.processing.org/t/rotate-all-ipoints-igeo-library/28950 "2021-03-29T15:32:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![AmbervanDinther](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/ambervandinther/32/12645_2.png) [@AmbervanDinther](https://discourse.processing.org/u/AmbervanDinther)\
**Post date:** [March 29, 2021, 3:32pm UTC](https://discourse.processing.org/t/rotate-all-ipoints-igeo-library/28950/1 "2021-03-29T15:32:32Z")

</div>

Hi everyone!

I can’t seem to figure out how I can rotate my cube made out of iPoints. I guess I have to rotate each point around a pivitpoint which i place in the middle of all the iPoints. Can anyone give me a tip or help me out a bit?

Thank you so much!

```auto
import igeo.*;
import igeo.gui.*;
import igeo.io.*;
import igeo.p.*;

IPoint cube;
int i2, k2, j2;

void setup(){
  background(0);
  size( 600, 400, IG.GL );
  i2 = 10;
  k2 = 10;
  j2 = 10;
  
  background(0);
}

void draw () {
  //i2 += 1;
  //k2 += 1;
  //j2 += 1;
  drawCube();
}

void drawCube() {
  for(int i=0; i < 15; i++){
    for(int j=0; j < 15; j++){
      for(int k=0; k < 15; k++){
        cube = new IPoint(i*i2, j*j2, k*k2).clr(i*0.1, j*0.1, k*0.1);
      }
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![josephh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josephh/32/210_2.png) [@josephh](https://discourse.processing.org/u/josephh)\
**Post date:** [March 29, 2021, 8:46pm UTC](https://discourse.processing.org/t/rotate-all-ipoints-igeo-library/28950/2 "2021-03-29T20:46:52Z")

</div>

Hi,

Welcome to the forum! 😉

Can you please format your code by using the `</>` button when editing a message on the forum or use back ticks around your code : ```code``` → `code`

I’ve never used the iGeo library but I suppose you can use the Processing’s transformation functions like [`translate()`](https://processing.org/reference/translate_.html) or [`rotate()`](https://processing.org/reference/rotate_.html).

If you are new to this, I suggest you look at the tutorial on transforms in 2D (which can generalize in 3D as well) :

[https://processing.org/tutorials/transform2d/](https://processing.org/tutorials/transform2d/)

And also for 3d :

[https://processing.org/tutorials/p3d/](https://processing.org/tutorials/p3d/)

---

<div class="post-metadata">

**Author:** ![micuat](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/micuat/32/19407_2.png) [@micuat](https://discourse.processing.org/u/micuat)\
**Post date:** [March 29, 2021, 10:50pm UTC](https://discourse.processing.org/t/rotate-all-ipoints-igeo-library/28950/3 "2021-03-29T22:50:55Z")

</div>

I haven’t tested (again, please format the code as joseph wrote) but I guess `rot` is the function you are looking for. It seems it returns another `IPoint` but not sure if it affects the original point instance.  
[http://igeo.jp/doc/igeo/IPoint.html#rot(double,%20double,%20double,%20double,%20double,%20double,%20double)](http://igeo.jp/doc/igeo/IPoint.html#rot(double,%20double,%20double,%20double,%20double,%20double,%20double))

(by the way Satoru the author of the library gave a keynote at our PCD last year 🙂)
