|
Author |
Topic: helix 1... (Read 3023 times) |
|
arielm
|
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
|
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
|
|
|
|