We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › Bending in 3d Space
Page Index Toggle Pages: 1
Bending in 3d Space (Read 436 times)
Bending in 3d Space
Oct 7th, 2009, 9:49am
 
I was thinking if there is an easy way to bend or twist or transform along a path, a helix like object i created.

Its for an upcoming data visualisation but i dont want it to be straight . Some turns would be nice.

In this thread, Dave mentioned, PMatrix but i was not sure if this would be an option in this case. Like i said, in the other post. I wish there would be some more documentation on PMatrix, as i coulnt find any beside the javadoc.

So what do you think, any easy way to bend the following?



Code:
  import processing.opengl.*;

void setup(){
 size(600,600,OPENGL);
}

float rx,ry;
void draw(){

translate(0,200,0);
rx+=((width/2-mouseX)*0.01f-rx)*0.1f;
 ry+=((height/2-mouseY)*0.01f-ry)*0.1f;
 rotateY(rx);
 rotateX(ry);

 randomSeed(10);
 background(241);
  noStroke();
 smooth();
 translate(width/2,height/2);
 segment(260 ,0,3600,60);

}
void segment(int resolution,int start, int end, int radius){
 beginShape(QUAD_STRIP);
 for(int i=0;i<resolution;i++){
   float d=radians(map(i,0,resolution-1,start,end));
  fill(map(i,0,resolution,0,255));
float xx = random(1.2,6.5);

  float lerpX = map(xx,1.2,6.5,0,1);
//   fill(lerpColor(#ff0000,#4400ff,lerpX),100);
  fill(255-xx*170,20);
 
  strokeWeight(0.4);
  stroke(lerpColor(#ff0000,#4400ff,lerpX));
   fill(map(i,0,resolution,255,0),0,200);
noStroke();
   vertex(sin(d)*(radius),cos(d)*(radius), i*4 );
   vertex(sin(d)*((radius+5)+10),cos(d)*((radius+5)+10), i*4 );
 }
 endShape();
}
Page Index Toggle Pages: 1