Vector copying in Android Mode

edited January 2017 in Android Mode

Hi,

I have a class that is passed a PVector in the constructor, which it then assigns to a variable using the .copy() function. However, in the console I get this error: this.velocity = _velocity.copy(); ^^^^ The method copy() is undefined for the type PVector

Can anyone help?

Thanks

Tagged:

Answers

  • // forum.Processing.org/two/discussion/20523/
    // vector-copying-in-android-mode#Item_2
    
    Vec cloned;
    
    void setup() {
      PVector original = new PVector(10, 20, 30);
      println(original);
    
      cloned = new Vec(original);
      cloned.vec.mult(30);
    
      println("cloned" + cloned);
      println("original" + original);
    
      exit();
    }
    
    class Vec {
      final PVector vec = new PVector();
    
      Vec(final PVector pv) {
        vec.set(pv);
      }
    
      @ Override String toString() {
        return vec.toString();
      }
    }
    
Sign In or Register to comment.