# Plotting (x,y,z) for helicoid

Hello,
I’m trying to render a helicoid in java by making an array list of vectors and then plotting the shape. Not entirely confident that my approach is a particularly good one but would appreciate any feedback and/or reason why the plots are so erratic.

``````
import peasy.*;

ArrayList<PVector> points = new ArrayList<PVector>();
float p;
PeasyCam cam;

void setup() {
size(800, 800, P3D);
background(20);
colorMode(HSB);
//cam = new PeasyCam(this , 5000);
}

void draw() {
noFill();
stroke(200,180,200);
strokeWeight(5);

translate(width / 2, height / 2);

points.add(new PVector(x(p++), y(p++), z(p++)));

beginShape();
for (PVector v : points) {
vertex(v.x, v.y, v.z);
}
endShape();

}

// HELICOID

float x(float p) {
return 100 * cos(p);
}

float y(float p) {
return 200 * -sin(p);
}

float z(float p) {
return 20 * pow(tan(PI/2 + p) , -1); // return p?
}
``````

Many thanks,
Callum

1 Like

Hello !

And welcome to the processing forum. Nice to have you here!

I think to add 1 three times to the angle p was just to much (it’s in radians, not degree!).

And also the function z is problematic!

Warm regards,

Chrisir

Full Code

``````

import peasy.*;

ArrayList<PVector> points = new ArrayList<PVector>();
float p;
PeasyCam cam;

void setup() {
size(800, 800, P3D);
background(20);
colorMode(HSB);
avoidClipping();
cam = new PeasyCam(this, 5000);
}

void draw() {
background(20);
lights();

points.add(new PVector(x(p), y(p), z(p)));
p+=0.0521;

showData();

cam.beginHUD();
fill(255);
text("Helicoid. Use peasycam.", 19, 19);
cam.endHUD();
}

//---------------------------------------------------------------------------

void showData() {
// show data in points

noFill();
stroke(200, 180, 200);
strokeWeight(5);

translate(width / 2, height / 2);

beginShape();
for (PVector v : points) {
vertex(v.x, v.y, v.z);
}
endShape();
}

//---------------------------------------------------------------------------
// HELICOID

float x(float p) {
return 100 * cos(p);
}

float y(float p) {
return 200 * sin(p);
}

float z(float p) {
// return 20 * pow(tan(PI/2 + p), -1); // return p?
//return tan(PI/2 + p); // return p?
return 10*p;
}

// --------------------------------------------------------------------------

void avoidClipping() {
// avoid clipping :
// https : //
// forum.processing.org/two/discussion/4128/quick-q-how-close-is-too-close-why-when-do-3d-objects-disappear
perspective(PI/3.0, (float) width/height, 1, 1000000);
}//func
//
``````
1 Like

new version with a for-loop for the radius at each angle

I tried to close the plane nicely using `TRIANGLE_STRIP` but to no avail. Needs further work.

``````

import peasy.*;

ArrayList<PVector> points = new ArrayList<PVector>();
float p;
PeasyCam cam;

int i;

void setup() {
size(800, 800, P3D);
background(20);
colorMode(HSB);
avoidClipping();
cam = new PeasyCam(this, 5000);
}

void draw() {
background(20);
lights();

for (i=20; i<100; i+=10) {
points.add(new PVector(x(p), y(p), z(p)));
}
p+=0.0521;

showData();

cam.beginHUD();
fill(255);
text("Helicoid. Use peasycam.", 19, 19);
cam.endHUD();
}

//---------------------------------------------------------------------------

void showData() {
// show data in points

noFill();
stroke(200, 180, 200);
strokeWeight(5);

translate(width / 2, height / 2);

beginShape(TRIANGLE_STRIP);
for (PVector v : points) {
vertex(v.x, v.y, v.z);
}
endShape();
}

//---------------------------------------------------------------------------
// HELICOID

float x(float p) {
return i * cos(p);
}

float y(float p) {
return (i+100) * -sin(p);
}

float z(float p) {
// return 20 * pow(tan(PI/2 + p), -1); // return p?
//return tan(PI/2 + p); // return p?
return 10*p;
}

// --------------------------------------------------------------------------

void avoidClipping() {
// avoid clipping :
// https : //
// forum.processing.org/two/discussion/4128/quick-q-how-close-is-too-close-why-when-do-3d-objects-disappear
perspective(PI/3.0, (float) width/height, 1, 1000000);
}//func
//
``````
1 Like

ahh thank you! Wasn’t aware of the you could avoid clipping so cheers dude!
Hopefully I’ll be able to make a hyperbolic helicoid from here!

1 Like

p is in radians. I misspelled that. I corrected it now.

I also put lights() in.

It looked at this, but I couldn’t make it work, your z():

``````return 20 * pow(tan(PI/2 + p), -1); // return p?
``````

Hello,

There are some references to clipping on the Processing site:

`:)`

3 Likes

I got my parametric equations from this site:
https://www.encyclopediaofmath.org/index.php/Helicoid

However most other sources suggest z = c * theta so I’m not sure what that expression particularly does.

2 Likes