# The function transform(PVector) does not exist

**URL:** https://discourse.processing.org/t/the-function-transform-pvector-does-not-exist/14668
**Category:** Beginners
**Created:** [October 13, 2019, 6:34pm UTC](https://discourse.processing.org/t/the-function-transform-pvector-does-not-exist/14668 "2019-10-13T18:34:21Z")
**Posts on this page:** 19
**Page:** 1

<div class="post-metadata">

### Author: ![mamamoo](https://avatars.discourse-cdn.com/v4/letter/m/ed8c4c/32.png) [@mamamoo](https://discourse.processing.org/u/mamamoo)
#### Post date: [October 13, 2019, 6:34pm UTC](https://discourse.processing.org/t/the-function-transform-pvector-does-not-exist/14668/1 "2019-10-13T18:34:21Z")

</div>

```auto
class StarField {  
  final int STAR_COUNT = width / 2;  
  final int MAX_SPEED = 11, MIN_SPEED = 1;  
  final int SPEED_STEP = 1;  
  ArrayList<Star> stars;  
  PVector endpoint;  
  int speed;  
  StarField() {  
    endpoint = new PVector(mouseX, mouseY);  
    stars = new ArrayList();  
    for (int i = 0; i < STAR_COUNT; i++) {  
      stars.add(new Star());
    }  
    speed = (MAX_SPEED + MIN_SPEED) / 2;
  }
  void run() {  
    for (Star s : stars) {  
      s.move(speed);  
      **s.transform(endpoint);
      **  
        s.checkEdge();  
      s.display();
    }
  }
  void updateEndpoint(float x, float y) {  
    endpoint.x = x;  
    endpoint.y = y;
  }  
  void speedUP() {  
    speed += SPEED_STEP;  
    speed = constrain(speed, MIN_SPEED, MAX_SPEED);
  }  
  void speedDown() {  
    speed -= SPEED_STEP;  
    speed = constrain(speed, MIN_SPEED, MAX_SPEED);
  }
}

```

---

<div class="post-metadata">

### Author: ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)
#### Post date: [October 13, 2019, 6:39pm UTC](https://discourse.processing.org/t/the-function-transform-pvector-does-not-exist/14668/2 "2019-10-13T18:39:23Z")

</div>

You should share your Star class as well – and a minimal sketch, if you have it.

It looks like you are calling myStar(myPVector), but your star class does not have a method

```
void transform (PVector pv){}
```

---

<div class="post-metadata">

### Author: ![mamamoo](https://avatars.discourse-cdn.com/v4/letter/m/ed8c4c/32.png) [@mamamoo](https://discourse.processing.org/u/mamamoo)
#### Post date: [October 13, 2019, 6:47pm UTC](https://discourse.processing.org/t/the-function-transform-pvector-does-not-exist/14668/3 "2019-10-13T18:47:19Z")

</div>

Thankyou for your fast reply!

Here’s my Star class:

```auto
class Star{  
final float MAX_DIAM = 16;  
final float MAX_DEPTH = width / 2;  
final float SCALE = MAX_DEPTH;  
PVector worldPosition, screenPosition, viewPosition;  
float diam;  
Star(){  
worldPosition = new PVector(random(0, width), random(0, height), random(0, MAX_DEPTH));  
}  
void move(float speed){  
worldPosition.z -= speed;  
worldPosition.z = constrain(worldPosition.z, 0, MAX_DEPTH);  
}  
void transfrom(PVector endpoint){  
viewPosition.x = (worldPosition.x - endpoint.x) / worldPosition.z * SCALE; 
viewPosition.y = (worldPosition.y - endpoint.y) / worldPosition.z * SCALE; 
viewPosition = PVector.sub(worldPosition, endpoint).div(worldPosition.z).mult(SCALE);  
screenPosition.x = endpoint.x + viewPosition.x; 
screenPosition.y = endpoint.y + viewPosition.y; 
screenPosition = PVector.add(endpoint, viewPosition);  
diam = map(worldPosition.z, 0, MAX_DEPTH, MAX_DIAM, 0);  
}  
void checkEdge(){  
if(screenPosition.x <= 0 || screenPosition.x >= width || screenPosition.y <=0 || screenPosition.y >= height){  
worldPosition.set(random(0, width), random(0, height), MAX_DEPTH);   
 }   
 }  
  
void display(){  
fill(255);  
noStroke();  
ellipse(screenPosition.x, screenPosition.y, diam, diam);  
}    
}

```

---

<div class="post-metadata">

### Author: ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)
#### Post date: [October 13, 2019, 6:48pm UTC](https://discourse.processing.org/t/the-function-transform-pvector-does-not-exist/14668/4 "2019-10-13T18:48:27Z")

</div>

transfrom --\> transform

---

<div class="post-metadata">

### Author: ![mamamoo](https://avatars.discourse-cdn.com/v4/letter/m/ed8c4c/32.png) [@mamamoo](https://discourse.processing.org/u/mamamoo)
#### Post date: [October 13, 2019, 6:51pm UTC](https://discourse.processing.org/t/the-function-transform-pvector-does-not-exist/14668/5 "2019-10-13T18:51:18Z")

</div>

I am so silly, thank you so much, I can’t believe I didn’t notice the typo. I pressed run and it now says Debugger busy…

When not using the PDE, size() can only be used inside settings().  
Remove the size() method from setup(), and add the following:  
public void settings() {  
size(400, 400);  
}

---

<div class="post-metadata">

### Author: ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)
#### Post date: [October 13, 2019, 6:56pm UTC](https://discourse.processing.org/t/the-function-transform-pvector-does-not-exist/14668/6 "2019-10-13T18:56:56Z")

</div>

Are you in Eclipse or Netbeans?

---

<div class="post-metadata">

### Author: ![mamamoo](https://avatars.discourse-cdn.com/v4/letter/m/ed8c4c/32.png) [@mamamoo](https://discourse.processing.org/u/mamamoo)
#### Post date: [October 13, 2019, 7:00pm UTC](https://discourse.processing.org/t/the-function-transform-pvector-does-not-exist/14668/7 "2019-10-13T19:00:24Z")

</div>

> [@jeremydouglass](#):
>
> Eclipse

I’ve just been using this.

 ![00](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/3/37d91535578a51a0aed9cc45aa00e48084646090.png)

---

<div class="post-metadata">

### Author: ![mamamoo](https://avatars.discourse-cdn.com/v4/letter/m/ed8c4c/32.png) [@mamamoo](https://discourse.processing.org/u/mamamoo)
#### Post date: [October 13, 2019, 7:05pm UTC](https://discourse.processing.org/t/the-function-transform-pvector-does-not-exist/14668/8 "2019-10-13T19:05:09Z")

</div>

![50](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/3/30950faf31b02932afb0287f6bf068088409b448.png)  
This is the latest update.

NullPointerException

---

<div class="post-metadata">

### Author: ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)
#### Post date: [October 13, 2019, 7:09pm UTC](https://discourse.processing.org/t/the-function-transform-pvector-does-not-exist/14668/9 "2019-10-13T19:09:20Z")

</div>

Ah. You renamed your sketch tab to “Main” – you can’t do that. This is Java – not C++.

Processing sketches are compiled as inner classes of their PApplet.

When you create a sketch and save it, it will always have the form:

/sketches/MySketch/MySketch.pde  
/sketches/Another/Another.pde  
/sketches/Foo/Foo.pde  
/sketches/Bar/Bar.pde

The “main” entrypoint pde file must match the name of its enclosing folder – which it will always do if you create a new sketch and save it, or if you Save As etc. from inside PDE. You will notice this is also true of every example in the Examples folders.

---

<div class="post-metadata">

### Author: ![mamamoo](https://avatars.discourse-cdn.com/v4/letter/m/ed8c4c/32.png) [@mamamoo](https://discourse.processing.org/u/mamamoo)
#### Post date: [October 13, 2019, 7:22pm UTC](https://discourse.processing.org/t/the-function-transform-pvector-does-not-exist/14668/10 "2019-10-13T19:22:16Z")

</div>

Hi, again this is the new update. I don’t understand where I should make the change. What’s wrong with the size?

StarField sf;  
void setup(){  
size(400, 400);  
sf = new StarField();  
}

void draw(){  
background(0);  
sf.run();  
}

void mousePressed(){  
if(mouseButton == LEFT){  
sf.speedUP();  
}else if(mouseButton == RIGHT){  
sf.speedDown();  
}  
}  
void mouseMoved(){  
sf.updateEndpoint(mouseX, mouseY);  
}

 ![30](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/a/a22040482828dad3e266f06bbb4d3ea84de42d2f.png)

---

<div class="post-metadata">

### Author: ![mamamoo](https://avatars.discourse-cdn.com/v4/letter/m/ed8c4c/32.png) [@mamamoo](https://discourse.processing.org/u/mamamoo)
#### Post date: [October 13, 2019, 7:39pm UTC](https://discourse.processing.org/t/the-function-transform-pvector-does-not-exist/14668/11 "2019-10-13T19:39:25Z")

</div>

There are so many errors one after another, this is whole a mess now 😵

I now have no idea where to fix or change, thank you for your patience.

---

<div class="post-metadata">

### Author: ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)
#### Post date: [October 13, 2019, 8:10pm UTC](https://discourse.processing.org/t/the-function-transform-pvector-does-not-exist/14668/12 "2019-10-13T20:10:28Z")

</div>

> [@jeremydouglass](#):
>
> Ah. You renamed your sketch tab to “Main” – you can’t do that.

Are you modifying a sketch that you found somewhere? Is this your first time using Processing? Are you new to programmming? I’m just trying to get a sense of where you are coming from, and where this code came from.

---

<div class="post-metadata">

### Author: ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)
#### Post date: [October 13, 2019, 8:14pm UTC](https://discourse.processing.org/t/the-function-transform-pvector-does-not-exist/14668/13 "2019-10-13T20:14:06Z")

</div>

1. create a brand new sketch.
2. save it with a meaningful name, like StarFieldTest. The name may not be the name of a class in your sketch.
3. add this code to the main tab, “StarFieldTest”

```auto
void setup(){
  size(400, 400);
}

void draw(){
  background(0);
}

```

1. Save, then run it. Does it work?

---

<div class="post-metadata">

### Author: ![mamamoo](https://avatars.discourse-cdn.com/v4/letter/m/ed8c4c/32.png) [@mamamoo](https://discourse.processing.org/u/mamamoo)
#### Post date: [October 13, 2019, 8:21pm UTC](https://discourse.processing.org/t/the-function-transform-pvector-does-not-exist/14668/14 "2019-10-13T20:21:09Z")

</div>

Hi, yes I am new to programming, completely new and this code came from a tutorial.

---

<div class="post-metadata">

### Author: ![mamamoo](https://avatars.discourse-cdn.com/v4/letter/m/ed8c4c/32.png) [@mamamoo](https://discourse.processing.org/u/mamamoo)
#### Post date: [October 13, 2019, 8:29pm UTC](https://discourse.processing.org/t/the-function-transform-pvector-does-not-exist/14668/15 "2019-10-13T20:29:41Z")

</div>

Hello, I have inserted the set of code in the new file created.

 ![34](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/3/39888bd2374e72edc44f70f459e4b63a3599a10d.png)

---

<div class="post-metadata">

### Author: ![mamamoo](https://avatars.discourse-cdn.com/v4/letter/m/ed8c4c/32.png) [@mamamoo](https://discourse.processing.org/u/mamamoo)
#### Post date: [October 13, 2019, 8:30pm UTC](https://discourse.processing.org/t/the-function-transform-pvector-does-not-exist/14668/16 "2019-10-13T20:30:29Z")

</div>

This showed after after run.

 ![16](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/1/1625f89293337c45db126cc925b4ab72b4b85a48.png)

---

<div class="post-metadata">

### Author: ![Tiemen](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tiemen/32/5477_2.png) [@Tiemen](https://discourse.processing.org/u/Tiemen)
#### Post date: [October 13, 2019, 10:29pm UTC](https://discourse.processing.org/t/the-function-transform-pvector-does-not-exist/14668/17 "2019-10-13T22:29:25Z")

</div>

When the error says **duplicate method setup()** it means there’s two methods called ‘setup’. Keep in mind that, throughout your entire sketch (this includes all the tabs), you can’t have functions or methods with the same name (there are exceptions, but for now my advice is to assume it’s not possible).

For instance, the following code won’t run because there are two duplicate function names:

```auto
void setup() {
  size(500, 500);
}

void draw() {
  background(240);
  stroke(0);
  fill(255, 0, 0);
  drawRectangle();
}

void drawRectangle() {
  rect(100, 100, 300, 200);
}

void drawRectangle() { // try renaming this function and it will work
  rect(100, 100, 200, 300);  
}

```

---

<div class="post-metadata">

### Author: ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)
#### Post date: [October 14, 2019, 5:01am UTC](https://discourse.processing.org/t/the-function-transform-pvector-does-not-exist/14668/18 "2019-10-14T05:01:31Z")

</div>

It is up to you, but just so you know, this code is not recommended for a beginner learning programming – you don’t usually want to start with multi-tab sketches or classes. Instead, learn the basics first:

[https://processing.org/tutorials/](https://processing.org/tutorials/)

If not, remove Star.pde, Main.pde, and StarField.pde, and add their parts back in slowly a bit at a time. Start with a working sketch that does nothing. That way it will always be clear what you just changed that broke things.

---

<div class="post-metadata">

### Author: ![mamamoo](https://avatars.discourse-cdn.com/v4/letter/m/ed8c4c/32.png) [@mamamoo](https://discourse.processing.org/u/mamamoo)
#### Post date: [October 14, 2019, 6:31pm UTC](https://discourse.processing.org/t/the-function-transform-pvector-does-not-exist/14668/19 "2019-10-14T18:31:43Z")

</div>

Hello,

Thank you so much for being this patient with me, I realised that I will need to take it slowly since there’s always an error after another. I am going to watch the tutorials and learn more about it, hopefully I can get it to run.

J
