FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Programming Questions & Help
   Syntax
(Moderators: fry, REAS)
   rotate where?
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: rotate where?  (Read 377 times)
st33d

WWW Email
rotate where?
« on: Mar 30th, 2005, 1:28am »

I want to have a string of text operate like an x,y,z line. I'm assuming rotateX,Y,Z will do this for me if I pack it in with a function to put the text to a translated point. But it doesn't. I haven't got the slightest clue in what direction I need to point the text. I've tried pretty much every atan2 combination I can think of and I'm still getting nowhere.
Code:

void setup(){
size(400,400);
fill(0);
}
void loop(){
background(255);
translate(200,200);
rotateY((PI/width)*mouseX);
rotateX((PI/width)*mouseY);
line(0,0,0,200,200,200);
textLine(0,0,0,200,200,200);
}
void textLine(float x1, float y1, float z1, float x2, float y2, float z2){
  push();
  float dx = x2-x1;
  float dy = y2-y1;
  float dz = z2-z1;
  translate(x1,y1,z1);
  /*
  dx,dy
  dy,dx
  dx,dz
  dz,dx
  dy,dz
  dz,dy
  */
  float thetaX = atan2(dy,dz);
  float thetaY = atan2(dz,dx);
  float thetaZ = atan2(dy,dx);
  rotateX(thetaX);
  rotateY(thetaY);
  rotateZ(thetaZ);
  //text(message,0,0);
  rect(0,0,200,4);
  pop();
}
 

Please help.
« Last Edit: Mar 30th, 2005, 1:50am by st33d »  

I could murder a pint.
Pages: 1 

« Previous topic | Next topic »