Creating new PVector instance from an existing one

I'm just going through the nature of code and I've got to this part

So creating the first one is straight forward, but I'm not sure how to go about making the second one equal to the first multiplied by two

What I wanted to do was :

PVector v = new PVector (1,5);
PVector u = new PVector(v.x*2,v.y*2);

But that can't be correct as the dot method is used in the example...

So I'm not sure how to go about that, I'm aware that there are the static methods add(), sub(), mult, div() in the PVector class, but I'm not sure how to go about using them in this instance.

I've tried bashing about with things such as

PVector u = PVector.add(v.mult(2));

But that's obviously wrong.

Any help appreciated, cheers

Answers

Sign In or Register to comment.