# Plotting (x,y,z) for helicoid

**URL:** <https://discourse.processing.org/t/plotting-x-y-z-for-helicoid/18910>\
**Category:** Coding Questions\
**Created:** [March 22, 2020, 9:46pm UTC](https://discourse.processing.org/t/plotting-x-y-z-for-helicoid/18910 "2020-03-22T21:46:35Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![rubbs](https://avatars.discourse-cdn.com/v4/letter/r/838e76/32.png) [@rubbs](https://discourse.processing.org/u/rubbs)\
**Post date:** [March 22, 2020, 9:46pm UTC](https://discourse.processing.org/t/plotting-x-y-z-for-helicoid/18910/1 "2020-03-22T21:46:35Z")

</div>

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.

```auto

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

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [March 22, 2020, 10:12pm UTC](https://discourse.processing.org/t/plotting-x-y-z-for-helicoid/18910/2 "2020-03-22T22:12:35Z")

</div>

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**

```auto

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
//

```

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [March 22, 2020, 10:17pm UTC](https://discourse.processing.org/t/plotting-x-y-z-for-helicoid/18910/3 "2020-03-22T22:17:08Z")

</div>

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.

Cf. [https://github.com/Kango/3DSketches/tree/master/Moebius4](https://github.com/Kango/3DSketches/tree/master/Moebius4)

see [https://en.wikipedia.org/wiki/Helicoid](https://en.wikipedia.org/wiki/Helicoid)

```auto

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
//

```

---

<div class="post-metadata">

**Author:** ![rubbs](https://avatars.discourse-cdn.com/v4/letter/r/838e76/32.png) [@rubbs](https://discourse.processing.org/u/rubbs)\
**Post date:** [March 22, 2020, 10:37pm UTC](https://discourse.processing.org/t/plotting-x-y-z-for-helicoid/18910/4 "2020-03-22T22:37:27Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [March 22, 2020, 10:44pm UTC](https://discourse.processing.org/t/plotting-x-y-z-for-helicoid/18910/5 "2020-03-22T22:44:18Z")

</div>

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():

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

```

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [March 22, 2020, 10:47pm UTC](https://discourse.processing.org/t/plotting-x-y-z-for-helicoid/18910/6 "2020-03-22T22:47:28Z")

</div>

Hello,

> [@rubbs](#):
>
> Wasn’t aware of the you could avoid clipping

There are some references to clipping on the Processing site:

> [@Drawn object stops moving away?](https://discourse.processing.org/t/drawn-object-stops-moving-away/17493/3):
>
> Hello, Welcome to the forum. You are experiencing clipping. The Perspective section discusses this: [https://processing.org/tutorials/p3d/](https://processing.org/tutorials/p3d/) And you can adjust the z-far parameter using perspective(): [https://processing.org/reference/perspective\_.html](https://processing.org/reference/perspective_.html)

`:)`

---

<div class="post-metadata">

**Author:** ![rubbs](https://avatars.discourse-cdn.com/v4/letter/r/838e76/32.png) [@rubbs](https://discourse.processing.org/u/rubbs)\
**Post date:** [March 22, 2020, 10:51pm UTC](https://discourse.processing.org/t/plotting-x-y-z-for-helicoid/18910/7 "2020-03-22T22:51:29Z")

</div>

I got my parametric equations from this site:  
[https://www.encyclopediaofmath.org/index.php/Helicoid](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.
