Operation 
GLSL or "osl/vec4.h" 
PixAnvil 
THREE.Vector3 
Vector addition 
vec3 c=a+b; 
var c=a.p(b); 
var c=a.clone().addSelf(b); 
Incremental addition 
c+=d; 
c.pe(d); 
c.addSelf(d); 
Vector scaling 
vec3 s=a*0.5; 
var s=a.t(0.5); 
var s=a.clone().multiplyScalar(0.5); 
Vector average 
vec3 c=(a+b)*0.5; 
var c=a.p(b).t(0.5); 
var c=a.clone().add(b).multiplyScalar(0.5); 
Dot product 
float x=dot(a,b); 
 same > 
var x=a.dot(b); 
Cosine of angle between vectors 
float cos_ang=dot(a,b) /
(length(a)*length(b)); 
var cos_ang=a.dot(b) /
(a.length()*b.length()); 

Cross product 
vec3 d=cross(a,b); 
var d=a.clone().cross(b); // make new vector d.crossVectors(a,b); // assign old vector 

Make unit vector 
vec3 d=normalize(p); 
var d=p.clone().normalize(); 