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_
   Topics & Contributions
   Tools
(Moderator: REAS)
   helix 1...
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: helix 1...  (Read 3023 times)
arielm

WWW
helix 1...
« on: May 3rd, 2003, 2:42am »

a kind of useless parametrable helix (3d spiral), unless you press the H key to toggle between hypno and normal mode...
 
(well, helixes may have some utility in the future, when we start writing on them...)
 
viewable example at:
 
http://www.chronotext.org/bits/014
 
source code at:
 
http://www.chronotext.org/bits/014/helix_1.pde
 

Ariel Malka | www.chronotext.org
arielm

WWW
Re: helix 1...
« Reply #1 on: May 3rd, 2003, 2:47am »

hey (it's me again), if someone knows how to integrate:
 
d += dd / r;
r = r1 + d * dr;
 
from within the following context:
 
Code:

void drawHelix(float x, float y, float z, float turns, float r1, float r2, float h, float dd)
{
  // draws an helix with equidistant points (dd being the distance between each of them)
 
  float c = TWO_PI * turns;
  float dr = (r2 - r1) / c;
  float dz = h / c;
 
  float r = r1;
  float d = 0.0;
 
  stroke(255, 224, 0);
  beginShape(LINE_STRIP);
  do
  {
    vertex(x - sin(d) * r, y + cos(d) * r, z + d * dz);
    d += dd / r;
    r = r1 + d * dr;
  }
  while(d < c);
  endShape();
}

 
... just let me know, 10-x!
 

Ariel Malka | www.chronotext.org
arielm

WWW
Re: helix 1...
« Reply #2 on: May 8th, 2003, 3:05pm »

third part of this monologue
 
i found a linear solution to my helix problem (i.e. now it is possible to slide along arbitralely)
 
the drawHelix() code should now look like:
 
Code:

void drawHelix(float x, float y, float z, float turns, float r1, float r2, float h, float dd)
{
  // draws an helix with equidistant points (dd being the distance between 2 consecutive points)
 
  float d;
  float r = 0.0;
  float dr = 0.0;
 
  float l = TWO_PI * turns;
  float L = PI * turns * (r1 + r2);
  float dz = h / l;
 
  boolean conical = (abs(r1 - r2) > 0.5);  // avoids infinity and divisions by zero with cylindrical helices (r1 = r2)
  if (conical)
  {
    dr = (r2 - r1) / l;
  }
  else
  {
    r = r1;
  }
  
  stroke(255, 224, 0);
  beginShape(LINE_STRIP);
  for (float D = 0.0; D < L; D += dd)
  {
    if (conical)
    {
 r = sqrt(r1 * r1 + 2.0f * dr * D);
 d = (r - r1) / dr;
    }
    else
    {
      d = D / r;
    }
   vertex(x - sin(d) * r, y + cos(d) * r, z + d * dz);
  }
  endShape();
}

 
p.s: why is it important to be able to draw a curve with equidistant points?.. because then, you have control on "distance", and you can just start writing (correctly spaced) text on it...
« Last Edit: May 12th, 2003, 11:26am by arielm »  

Ariel Malka | www.chronotext.org
Pages: 1 

« Previous topic | Next topic »