# Hallo! Can you explain me why my text doesn't spinning?

**URL:** <https://discourse.processing.org/t/hallo-can-you-explain-me-why-my-text-doesnt-spinning/10288>\
**Category:** Coding Questions\
**Created:** [April 15, 2019, 8:10am UTC](https://discourse.processing.org/t/hallo-can-you-explain-me-why-my-text-doesnt-spinning/10288 "2019-04-15T08:10:01Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![fwtini](https://avatars.discourse-cdn.com/v4/letter/f/9d8465/32.png) [@fwtini](https://discourse.processing.org/u/fwtini)\
**Post date:** [April 15, 2019, 8:10am UTC](https://discourse.processing.org/t/hallo-can-you-explain-me-why-my-text-doesnt-spinning/10288/1 "2019-04-15T08:10:01Z")

</div>

```auto
PFont myFont;

String s1= ("OBECALP PHARMACY ");
float angleSpeed= TWO_PI/s1.length();
float letterX,letterY;
int i,cntX,cntY;
int radius =260;

float z=random(TWO_PI);
float x;
float y;

//float rotX,rotY,rotZ;

float r = 100;
float angVel = -TWO_PI / 360;
float ang;

void setup() {
  size(800, 800, P3D);
  background(255);
  myFont = createFont("DrukTextWide-Heavy.ttf", 20);
  //textFont(myFont);
frameRate(20);

  
}

void draw() {
background(255);

rotate(ang);
  ang += angVel;
  
  float arclength = 0.4;
  for (int i = 0; i < s1.length (); i ++ ) {
    char currentChar = s1.charAt(i);
    float w = textWidth(currentChar);
    arclength += w/2;
    float theta = PI + arclength / r;
arclength += 0.2;

i=s1.length();
printQuote();
}}

void printQuote(){
  
  //camera(70,30,z,120,50,50,0,0,1);
  
int cntX = width/2, cntY =0;
for (int j = 0; j < i; j++) {

    letterX = cntX + radius * cos(j*angleSpeed);
    letterY = cntY + radius * sin(j*angleSpeed);
 
 
// rotX += 0.0003;
 // rotY += 0.0005;
 // rotZ += 0.0007;
 
  pushMatrix();
 //rotateX(rotX);
 // rotateY(rotX);
  //rotateZ(rotX);
  
 translate(letterX, 300, letterY);
 textSize(20);
 fill(0, 0, 0);
 text(s1.charAt(j),0,0);
  popMatrix();
      
}
//z+=0.1;
}

```

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [April 15, 2019, 8:49am UTC](https://discourse.processing.org/t/hallo-can-you-explain-me-why-my-text-doesnt-spinning/10288/2 "2019-04-15T08:49:32Z")

</div>

You have one Rotation like planets around the sun in the function printQuote

Then you have one rotation ang before the for loop

Which one doesn’t work? The latter?

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [April 15, 2019, 9:16am UTC](https://discourse.processing.org/t/hallo-can-you-explain-me-why-my-text-doesnt-spinning/10288/3 "2019-04-15T09:16:06Z")

</div>

In the for loop in draw() you have a lot of angles but you never use them - maybe this is the problem?

In 3D there is rotateX, rotateY and rotateZ for the different axis x,y,z

With a plane you call them yaw roll and pitch

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [April 15, 2019, 9:22am UTC](https://discourse.processing.org/t/hallo-can-you-explain-me-why-my-text-doesnt-spinning/10288/4 "2019-04-15T09:22:24Z")

</div>

> [@fwtini](#):
>
> rotate(ang);

Try rotateX or rotateZ or rotateY here

---

<div class="post-metadata">

**Author:** ![fwtini](https://avatars.discourse-cdn.com/v4/letter/f/9d8465/32.png) [@fwtini](https://discourse.processing.org/u/fwtini)\
**Post date:** [April 15, 2019, 10:54am UTC](https://discourse.processing.org/t/hallo-can-you-explain-me-why-my-text-doesnt-spinning/10288/5 "2019-04-15T10:54:06Z")

</div>

Oh I fixed it! it’s the r in rotateY  
thank you!!! 😄

---

<div class="post-metadata">

**Author:** ![fwtini](https://avatars.discourse-cdn.com/v4/letter/f/9d8465/32.png) [@fwtini](https://discourse.processing.org/u/fwtini)\
**Post date:** [April 15, 2019, 10:58am UTC](https://discourse.processing.org/t/hallo-can-you-explain-me-why-my-text-doesnt-spinning/10288/6 "2019-04-15T10:58:59Z")

</div>

hmm but if i want to spinning only the text… what do you recomend

---

<div class="post-metadata">

**Author:** ![fwtini](https://avatars.discourse-cdn.com/v4/letter/f/9d8465/32.png) [@fwtini](https://discourse.processing.org/u/fwtini)\
**Post date:** [April 15, 2019, 11:00am UTC](https://discourse.processing.org/t/hallo-can-you-explain-me-why-my-text-doesnt-spinning/10288/7 "2019-04-15T11:00:26Z")

</div>

recommend\*… and can you please tell me about the yaw roll and pitch?  
it’s like functions for rotation

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [April 15, 2019, 11:08am UTC](https://discourse.processing.org/t/hallo-can-you-explain-me-why-my-text-doesnt-spinning/10288/8 "2019-04-15T11:08:39Z")

</div>

> [@fwtini](#):
>
> want to spinning only the text

Yeah in the function add something to the angles you use for cos and sin. Increase this something.

About [yaw roll pitch - Google Search](https://www.google.com/search?q=yaw%20roll%20pitch) google it. It’s like with a plane it can rotate around one of the 3 axis. You can tilt your letter circle left/right or front / backside (or both) or/and around y axis as well

---

<div class="post-metadata">

**Author:** ![fwtini](https://avatars.discourse-cdn.com/v4/letter/f/9d8465/32.png) [@fwtini](https://discourse.processing.org/u/fwtini)\
**Post date:** [April 15, 2019, 12:23pm UTC](https://discourse.processing.org/t/hallo-can-you-explain-me-why-my-text-doesnt-spinning/10288/9 "2019-04-15T12:23:08Z")

</div>

i think it’s about int cntY =0, cntX =width/2; this function when i add  
int cntY =0, cntX =width/20; look it’s in the middle but how can i take it in the center???=/

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [April 15, 2019, 12:25pm UTC](https://discourse.processing.org/t/hallo-can-you-explain-me-why-my-text-doesnt-spinning/10288/10 "2019-04-15T12:25:23Z")

</div>

cnt is about the center in x and z (depth) direction

Height of the circle is 300 in the translate line in the function printQuote

Just change the values to find out. The function printQuote is your core code section where the important parts happen. I am not at home right now and can’t do it for you.

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [April 15, 2019, 12:26pm UTC](https://discourse.processing.org/t/hallo-can-you-explain-me-why-my-text-doesnt-spinning/10288/11 "2019-04-15T12:26:31Z")

</div>

> [@Chrisir](#):
>
> in the function add something to the angles you use for cos and sin. Increase this something.

Did you do this? It makes the letter travel around the sun like planets do around the sun

Your descriptions are also unclear for me sometimes

What exactly do you want to achieve?

Chrisir

---

<div class="post-metadata">

**Author:** ![fwtini](https://avatars.discourse-cdn.com/v4/letter/f/9d8465/32.png) [@fwtini](https://discourse.processing.org/u/fwtini)\
**Post date:** [April 15, 2019, 1:43pm UTC](https://discourse.processing.org/t/hallo-can-you-explain-me-why-my-text-doesnt-spinning/10288/12 "2019-04-15T13:43:13Z")

</div>

different motions with this string of letters!

---

<div class="post-metadata">

**Author:** ![fwtini](https://avatars.discourse-cdn.com/v4/letter/f/9d8465/32.png) [@fwtini](https://discourse.processing.org/u/fwtini)\
**Post date:** [April 15, 2019, 1:50pm UTC](https://discourse.processing.org/t/hallo-can-you-explain-me-why-my-text-doesnt-spinning/10288/13 "2019-04-15T13:50:34Z")

</div>

for example now I want to make the text spinning random in this code

```auto
final static int R = 1000;
float u, v;
float[][] stars;

PFont myFont;
String s1= ("OBECALP PHARMACY ");

int i, cntX, cntY; 
float letterX, letterY;
int radius = 260;
float angleSpeed = TWO_PI/s1.length();
float x, y;

void setup()
{
  size(800, 800, P3D);
  frameRate(30);
 // sphereDetail(1);
  myFont=createFont("Monaco", 14);
  stars = new float[1000][3];
  for(int i = 0; i < stars.length; i++)
  {
    float[] star = { random(-R, R), random(-R, R), random(-R, R) };
    stars[i] = star;
  }
}

void draw()
{
  i = s1.length(); 
  printQuote();
}

void printQuote() { 
  
int cntX = width/2, cntY = 0;

  for (int j = 0; j < i; j++) {

    letterX = cntX + radius * cos(j*angleSpeed);
    letterY = cntY + radius * sin(j*angleSpeed);

  
  u += (mouseY - height / 2.0) / height / 20;
  v += (mouseX - width / 2.0) / width / 20;
  
  
  background(0);
  //lights();
// camera(0, 0, 0, 0, 0, R, 0, 1, 0);
  rotateX(u); rotateY(v);
  noStroke();
  for(int i = 0; i < stars.length; i++)
  {
    pushMatrix();
       
    translate(stars[i][0], stars[i][1], stars[i][2]);
    
   
    popMatrix();
  }
  { pushMatrix();
  translate(letterX, 550, letterY);
  fill(0);
    text(s1.charAt(j),0,0);
    popMatrix();
  }
  camera();
  stroke(255);
  line(width / 2 - 5, height / 2 - 0, width / 2 + 4, height / 2 + 0);
  line(width / 2 - 0, height / 2 - 5, width / 2 + 0, height / 2 + 4);
  
}}

void mousePressed() { u = v = 0; } 

```

---

<div class="post-metadata">

**Author:** ![fwtini](https://avatars.discourse-cdn.com/v4/letter/f/9d8465/32.png) [@fwtini](https://discourse.processing.org/u/fwtini)\
**Post date:** [April 15, 2019, 1:51pm UTC](https://discourse.processing.org/t/hallo-can-you-explain-me-why-my-text-doesnt-spinning/10288/14 "2019-04-15T13:51:39Z")

</div>

I saw this amazing code and I want to add my text with rotation

```auto
final static int R = 1000;
float u, v;
float[][] stars;

void setup()
{
  size(800, 800, P3D);
  frameRate(30);
  sphereDetail(1);
  textFont(createFont("Monaco", 14));
  stars = new float[1000][3];
  for(int i = 0; i < stars.length; i++)
  {
    float[] star = { random(-R, R), random(-R, R), random(-R, R) };
    stars[i] = star;
  }
}

void draw()
{
  u += (mouseY - height / 2.0) / height / 20;
  v += (mouseX - width / 2.0) / width / 20;
  background(0);
  lights();
  camera(0, 0, 0, 0, 0, R, 0, 1, 0);
  rotateX(u); rotateY(v);
  noStroke();
  for(int i = 0; i < stars.length; i++)
  {
    pushMatrix();
    translate(stars[i][0], stars[i][1], stars[i][2]);
    sphere(5);
    popMatrix();
  }
  camera();
  stroke(255);
  line(width / 2 - 5, height / 2 - 0, width / 2 + 4, height / 2 + 0);
  line(width / 2 - 0, height / 2 - 5, width / 2 + 0, height / 2 + 4);
  text("u: " + int(degrees(u)) + " v: " + int(degrees(v)), 5, 17);
}

void mousePressed() { u = v = 0; } 

```

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [April 15, 2019, 4:37pm UTC](https://discourse.processing.org/t/hallo-can-you-explain-me-why-my-text-doesnt-spinning/10288/15 "2019-04-15T16:37:08Z")

</div>

I am sure you can do it

I am not at home now and can’t help you

---

<div class="post-metadata">

**Author:** ![fwtini](https://avatars.discourse-cdn.com/v4/letter/f/9d8465/32.png) [@fwtini](https://discourse.processing.org/u/fwtini)\
**Post date:** [April 15, 2019, 7:26pm UTC](https://discourse.processing.org/t/hallo-can-you-explain-me-why-my-text-doesnt-spinning/10288/16 "2019-04-15T19:26:10Z")

</div>

ok thank you anyway!

---

<div class="post-metadata">

**Author:** ![fwtini](https://avatars.discourse-cdn.com/v4/letter/f/9d8465/32.png) [@fwtini](https://discourse.processing.org/u/fwtini)\
**Post date:** [April 15, 2019, 11:28pm UTC](https://discourse.processing.org/t/hallo-can-you-explain-me-why-my-text-doesnt-spinning/10288/17 "2019-04-15T23:28:40Z")

</div>

if you want to help me… because I used so many functions but I don’t know how to do it… =/  
I want to have this 3D space and with my random text(// text(s1.charAt(j),0,0)😉 spinning around

```auto
PFont myFont;
String s1= ("OBECALP PHARMACY ");
float angleSpeed= TWO_PI/s1.length();
float letterX,letterY;
int i,cntX,cntY;
int radius =260;

float angVel = -TWO_PI / 560;
float ang;

final static int R = 1000;
float u, v;
float[][] stars;

void setup()
{
  size(800, 800, P3D);
  
    myFont = createFont("Serif-48.ttf", 20);
 // textFont(myFont);
 

  frameRate(30);
  sphereDetail(1);
  textFont(createFont("Monaco", 14));
  stars = new float[1000][5];
  for(int i = 0; i < stars.length; i++)
  {
    float[] star = { random(-R, R), random(-R, R), random(-R, R) };
    stars[i] = star;
  }
}

void draw()
{
  
  
  rotate(ang);
  ang += angVel;
  

i=s1.length();
printQuote();
}
  void printQuote(){
    int cntX = width/2, cntY =0;
    
for (int j = 0; j < i; j++) {

    letterX = cntX + radius * cos(j*angleSpeed);
    letterY = cntY + radius * sin(j*angleSpeed);
 

  
  u += (mouseY - height / 2.0) / height / 20;
  v += (mouseX - width / 2.0) / width / 20;
  background(0);

  rotateX(u); rotateY(v);
  noStroke();
  for(int i = 0; i < stars.length; i++)
  {
    pushMatrix();
    translate(stars[i][0], stars[i][1], stars[i][2]);
   sphere(3);
    translate(letterX, 300, letterY);
    textSize(20);

// text(s1.charAt(j),0,0);

    popMatrix();
  }
  camera();
  stroke(255);

}

  }

void mousePressed() { u = v = 0; } 

```

---

<div class="post-metadata">

**Author:** ![fwtini](https://avatars.discourse-cdn.com/v4/letter/f/9d8465/32.png) [@fwtini](https://discourse.processing.org/u/fwtini)\
**Post date:** [April 15, 2019, 11:31pm UTC](https://discourse.processing.org/t/hallo-can-you-explain-me-why-my-text-doesnt-spinning/10288/18 "2019-04-15T23:31:26Z")

</div>

sorry! (maybe I have to sleep! haha )

```auto
PFont myFont;
String s1= ("OBECALP PHARMACY ");
float angleSpeed= TWO_PI/s1.length();
float letterX,letterY;
int i,cntX,cntY;
int radius =260;

float angVel = -TWO_PI / 560;
float ang;

final static int R = 1000;
float u, v;
float[][] stars;

void setup()
{
  size(800, 800, P3D);
  
    myFont = createFont("Serif-48.ttf", 20);
 // textFont(myFont);
 

  frameRate(30);
  sphereDetail(1);
  textFont(createFont("Monaco", 14));
  stars = new float[1000][5];
  for(int i = 0; i < stars.length; i++)
  {
    float[] star = { random(-R, R), random(-R, R), random(-R, R) };
    stars[i] = star;
  }
}

void draw()
{
  
  
  rotate(ang);
  ang += angVel;
  

i=s1.length();
printQuote();
}
  void printQuote(){
    int cntX = width/2, cntY =0;
    
for (int j = 0; j < i; j++) {

    letterX = cntX + radius * cos(j*angleSpeed);
    letterY = cntY + radius * sin(j*angleSpeed);
 

  
  u += (mouseY - height / 2.0) / height / 20;
  v += (mouseX - width / 2.0) / width / 20;
  background(0);

  rotateX(u); rotateY(v);
  noStroke();
  for(int i = 0; i < stars.length; i++)
  {
    pushMatrix();
    translate(stars[i][0], stars[i][1], stars[i][2]);
   sphere(3);
    translate(letterX, 300, letterY);
    textSize(20);

// text(s1.charAt(j),0,0);

    popMatrix();
  }
  camera();
  stroke(255);

}

  }

void mousePressed() { u = v = 0; } 

```

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [April 18, 2019, 4:39pm UTC](https://discourse.processing.org/t/hallo-can-you-explain-me-why-my-text-doesnt-spinning/10288/19 "2019-04-18T16:39:34Z")

</div>

Also try draw() with these lines (they are commented out in the long code below)

```auto
   rotate(ang);
   ang += angVel;

```

Chrisir

**Full sketch:**

```auto
// PFont myFont;
String s1= ("OBECALP PHARMACY ");
float angleSpeed= TWO_PI/s1.length();
float letterX, letterY;
// int i;
int cntX, cntY;
int radius =260;

float angVel = -TWO_PI / 560;
float ang;
int j=0;

final static int R = 1000;

float u, v;
float[][] stars;

void setup()
{
  size(800, 800, P3D);

  // myFont = createFont("Serif-48.ttf", 20);
  // textFont(myFont);

  // frameRate(30);
  sphereDetail(1);
  textFont(createFont("Monaco", 14));

  // makes things slow but looks better:
  textMode(SHAPE);

  textSize(20);

  stroke(255);

  stars = new float[1000][5];
  for (int i = 0; i < stars.length; i++)
  {
    float[] star = { random(-R, R), random(-R, R), random(-R, R) };
    stars[i] = star;
  }
}

void draw()
{
  background(0);

  // rotate(ang);
  // ang += angVel;

  //i=s1.length();
  printQuote();
}

void printQuote() {
  // int cntX = width/2, cntY =0;

  u += (mouseY - height / 2.0) / height / 20;
  v += (mouseX - width / 2.0) / width / 20;

  rotateX(u); 
  rotateY(v);

  for (int i = 0; i < stars.length; i++)
  {
    translate(stars[i][0], stars[i][1], stars[i][2]);
    text(s1.charAt(j), 0, 0);
    translate(-stars[i][0], -stars[i][1], -stars[i][2]);

    j++; 
    if (j>=s1.length())
      j=0;
  }//for
}//func 

void mousePressed() { 
  u = v = 0;
}

```

---

<div class="post-metadata">

**Author:** ![fwtini](https://avatars.discourse-cdn.com/v4/letter/f/9d8465/32.png) [@fwtini](https://discourse.processing.org/u/fwtini)\
**Post date:** [April 16, 2019, 9:44am UTC](https://discourse.processing.org/t/hallo-can-you-explain-me-why-my-text-doesnt-spinning/10288/20 "2019-04-16T09:44:41Z")

</div>

Now it stops spinning but it’s in the center haha now can i do to spinning =/

```auto
PFont myFont;

String s1= ("OBECALP PHARMACY ");
float angleSpeed= TWO_PI/s1.length();
float letterX,letterY;
int i,cntX,cntY;
int radius =260;

float z=random(TWO_PI);
float x=0;
float y;
float r =0;

float angle,c,x1,y1=0;
float speed = 0;
int waveStrengthHorizontal= 5;
int waveStrengthVertical= 5;

float u,v;
void setup() {
  size(800, 800, P3D);
  background(255);
  myFont = createFont("DrukTextWide-Heavy.ttf", 20);
  //textFont(myFont);
frameRate(20);
}

void draw() {
background(255);

i=s1.length();
printQuote();
}

void printQuote(){
  
 
  
int count =0;
for(y=0; y<500; y++){
if(count%10==0)
  {
  
int cntY =0, cntX =width/2;
for (int j = 0; j < i; j++) 

{
    letterX = cntX + radius * cos(j*angleSpeed);
    letterY = cntY + radius * sin(j*angleSpeed);
    
    
     
          
pushMatrix();

//rotateY(r);
//rotateX(200);

 translate(letterX, cntY, letterY);
 textSize(20);
 
 fill(0, 0, 0);
 text(s1.charAt(j),x,y);
 

  popMatrix();
  
}
}
count++;
//r=r+0.0001; angle+=10;
//speed=0.01;
  }
}

```

[Next page](https://discourse.processing.org/t/hallo-can-you-explain-me-why-my-text-doesnt-spinning/10288.md?page=2)
