# Implements an interface of a library

**URL:** https://discourse.processing.org/t/implements-an-interface-of-a-library/1928
**Category:** Libraries
**Created:** [July 20, 2018, 5:50am UTC](https://discourse.processing.org/t/implements-an-interface-of-a-library/1928 "2018-07-20T05:50:12Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![vjjv](https://avatars.discourse-cdn.com/v4/letter/v/df705f/32.png) [@vjjv](https://discourse.processing.org/u/vjjv)
#### Post date: [July 20, 2018, 5:50am UTC](https://discourse.processing.org/t/implements-an-interface-of-a-library/1928/1 "2018-07-20T05:50:12Z")

</div>

hello. im trying to create a path tube with shape3D library, but i have a problem to implements a I\_PathGen interface… is the first time that i “implements” a interface and i dont know how exactly make it works.

```auto
import shapes3d.*;
import shapes3d.animation.*;
import shapes3d.utils.*;

I_PathGen[] pathh;
PathTube path;
Points points;

Tube tube;
PeasyCam cam;

void setup() {
 
  size(600, 600, P3D);

  pathh = new I_PathGen[20];

  pathh[0] = new Points();
  pathh[0].x(1000);
  pathh[0].y(100);
  pathh[0].z(100);

  path = new PathTube(this, pathh[0], 5, 300, 10, false);
  path.fill(color(0, 255, 0), S3D.E_CAP);
}

void draw() {

  background(0);

  path.draw();
}

class Points implements I_PathGen {

}

```

the reference of I\_PathGen

> <https://github.com/firmread/Processing/blob/master/libraries/shapes3d/src/shapes3d/utils/I_PathGen.java>

thanks a lot…

---

<div class="post-metadata">

### Author: ![jb4x](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jb4x/32/789_2.png) [@jb4x](https://discourse.processing.org/u/jb4x)
#### Post date: [July 20, 2018, 5:59am UTC](https://discourse.processing.org/t/implements-an-interface-of-a-library/1928/2 "2018-07-20T05:59:18Z")

</div>

Hello,

When you implement an interface, you need to define some functions listed in the interface.

In that case, you need to define the 3 following functions in your class :

- public float x(float t);
- public float y(float t);
- public float z(float t);

For more explanations :

> <https://stackoverflow.com/questions/1913098/what-is-the-difference-between-an-interface-and-abstract-class>

---

<div class="post-metadata">

### Author: ![vjjv](https://avatars.discourse-cdn.com/v4/letter/v/df705f/32.png) [@vjjv](https://discourse.processing.org/u/vjjv)
#### Post date: [July 20, 2018, 6:01am UTC](https://discourse.processing.org/t/implements-an-interface-of-a-library/1928/3 "2018-07-20T06:01:51Z")

</div>

some like this ?

maybe need also some information about this library…

```auto
import shapes3d.*;
import shapes3d.animation.*;
import shapes3d.utils.*;

I_PathGen[] pathh;
PathTube path;
Points points;

Tube tube;
PeasyCam cam;

void setup() {
 
  size(600, 600, P3D);

  pathh = new I_PathGen[20];

  pathh[0] = new Points(0, 0,0);
  pathh[0].x(1000);
  pathh[0].y(100);
  pathh[0].z(100);

  path = new PathTube(this, pathh[0], 5, 300, 10, false);
  path.fill(color(0, 255, 0), S3D.E_CAP);
}

void draw() {

  background(0);

  path.draw();
}

class Points implements I_PathGen {

float xx, yy, zz;

Points (float _x, float _y, float _z){
xx = _x;
yy = _y;
zz = _z;
}

public float x(float t){
return t;
}
public float y(float t){
return t;
}
public float z(float t){
return t;
}

}

```

---

<div class="post-metadata">

### Author: ![jb4x](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jb4x/32/789_2.png) [@jb4x](https://discourse.processing.org/u/jb4x)
#### Post date: [July 20, 2018, 6:05am UTC](https://discourse.processing.org/t/implements-an-interface-of-a-library/1928/4 "2018-07-20T06:05:31Z")

</div>

Yep, looks good to me.

---

<div class="post-metadata">

### Author: ![vjjv](https://avatars.discourse-cdn.com/v4/letter/v/df705f/32.png) [@vjjv](https://discourse.processing.org/u/vjjv)
#### Post date: [July 20, 2018, 6:09am UTC](https://discourse.processing.org/t/implements-an-interface-of-a-library/1928/5 "2018-07-20T06:09:03Z")

</div>

thanks. but still dont understand. i just wanna connect two points with a tube… but i dont find any example. this is ok?

```auto
class Points implements I_PathGen {

float xx, yy, zz;

Points (float _x, float _y, float _z){
xx = _x;
yy = _y;
zz = _z;
}

public float x(float t){
t = xx;
return t;
}
public float y(float t){
t = yy;
return t;
}
public float z(float t){
t = zz;
return t;
}

}

```

cos i expected to set a point but this dont display anything

---

<div class="post-metadata">

### Author: ![jb4x](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jb4x/32/789_2.png) [@jb4x](https://discourse.processing.org/u/jb4x)
#### Post date: [July 20, 2018, 6:13am UTC](https://discourse.processing.org/t/implements-an-interface-of-a-library/1928/6 "2018-07-20T06:13:18Z")

</div>

I don’t know the library so I can’t be 100% sure but I don’t think that you need to set all the points manually.

The 3 functions x, y, and z are the equations that defines the shape of your path.

So when you write :

```auto
public float x(float t){
return t;
}
public float y(float t){
return t;
}
public float z(float t){
return t;
}

```

You are actually building a straight path that follows :  
x(t) = t  
y(t) = t  
z(t) = t

I’m afraid I can’t really help more than that

---

<div class="post-metadata">

### Author: ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)
#### Post date: [July 20, 2018, 6:13am UTC](https://discourse.processing.org/t/implements-an-interface-of-a-library/1928/7 "2018-07-20T06:13:24Z")

</div>

> [@vjjv](#):
>
> ```auto
> float x(float t) {
> t = xx;
> return t;
> }
> 
> ```

Parameters die along its function, so it’s useless to re-assign them! 😐

I believe you were meant to assign the **x()**'s _t_ parameter to the Points::_xx_ field instead: `xx = t;` 🤔

```auto
@Override float x(final float t) {
  return xx = t;
}

```

---

<div class="post-metadata">

### Author: ![vjjv](https://avatars.discourse-cdn.com/v4/letter/v/df705f/32.png) [@vjjv](https://discourse.processing.org/u/vjjv)
#### Post date: [July 20, 2018, 6:21am UTC](https://discourse.processing.org/t/implements-an-interface-of-a-library/1928/8 "2018-07-20T06:21:31Z")

</div>

```auto
import shapes3d.*;
import shapes3d.animation.*;
import shapes3d.utils.*;

I_PathGen[] pathh;
PathTube path;
Points points;

Tube tube;

void setup() {
 
  size(600, 600, P3D);

  pathh = new I_PathGen[20];

  pathh[0] = new Points(2, 500, 6);

  path = new PathTube(this, pathh[0], 50, 300, 10, false);
  path.fill(color(0, 255, 0), S3D.E_CAP);
}

void draw() {

  background(0);

  translate(width/2, height/2);
  path.draw();
}

class Points implements I_PathGen {

float xx, yy, zz;

Points (float _x, float _y, float _z){
xx = _x;
yy = _y;
zz = _z;
}

@Override float x(final float t) {
  return xx = t;
}

@Override float y(final float t) {
  return yy = t;
}
@Override float z(final float t) {
  return zz = t;
}

}

```

try this and this is the result… dont know, im so lost…

 ![screen-0039](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/1X/021ef52ae2102a2f3129645cb30d206eebb51057.jpg)

---

<div class="post-metadata">

### Author: ![kfrajer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kfrajer/32/196_2.png) [@kfrajer](https://discourse.processing.org/u/kfrajer)
#### Post date: [July 20, 2018, 6:38pm UTC](https://discourse.processing.org/t/implements-an-interface-of-a-library/1928/9 "2018-07-20T18:38:51Z")

</div>

Did you check the documentation?

Lib page: [http://www.lagers.org.uk/s3d4p/index.html](http://www.lagers.org.uk/s3d4p/index.html)

Doc: [http://www.lagers.org.uk/s3d4p/ref/classshapes3d\_1\_1\_path\_tube.html](http://www.lagers.org.uk/s3d4p/ref/classshapes3d_1_1_path_tube.html)

What do you want to do?

Kf

---

<div class="post-metadata">

### Author: ![vjjv](https://avatars.discourse-cdn.com/v4/letter/v/df705f/32.png) [@vjjv](https://discourse.processing.org/u/vjjv)
#### Post date: [July 21, 2018, 4:06am UTC](https://discourse.processing.org/t/implements-an-interface-of-a-library/1928/10 "2018-07-21T04:06:07Z")

</div>

I want to connect two points with a tube. first in a rect line, later, generate a spline or bezier curve
