Operation |
GLSL or "osl/vec3.h" |
THREE.Vector3; |
Vector addition |
vec3 c=a+b; |
var c=a.clone().addSelf(b); |
Incremental addition |
c+=d; |
c.addSelf(d); |
Vector scaling |
vec3 s=a*0.5; |
var s=a.clone().multiplyScalar(0.5); |
Dot product |
float x=dot(a,b); |
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()); |
Make unit vector |
vec3 d=normalize(p); |
var d=p.clone().normalize(); |