position & velocity

class Walker {
	constructor(x,y) {
	this.pos = createVector(x,y);
	this.vel = createVector(1,0);
	}
	
	update(){
	this.pos.x = this.pos.x + this.vel.x;
	this.pos.y = this.pos.y + this.vel.y;
	
	//or this.pos.add(this.vel);
	}
	show(){
	}}

add

let v1 = createVector(1,2,3);
let v2 = createVector(4,5,6);
let new Pos = p5.Vector.add(v1,v2);
let v = createVector(1,2,3);
v.add(4,5,6);

rotate

scale

translate(width/2,height/2);
//let v = createVector(random(-100));
v = p5.Vector.random2D(); //fromAngle(angle, [length]);
v.mult(random(50,100));

Inclass:

Tensor 张量

JAVAScript only knows using “+” with numbers.

So use “add” here to add vectors together.

indexV.add(thumbV);
indexV.mult(0.5); //manipulate原来的vector

V = p5.Vector.add(indexV,thumbV).mult(0.5); //创建一个新的vector来储存操作过后的vector

V = createVector(1,2); //createVector是唯一不需要引用p5.Vector的function