Skip to content

Commit

Permalink
added Vec3.prototype.addScaledVector
Browse files Browse the repository at this point in the history
  • Loading branch information
schteppe committed Apr 26, 2015
1 parent 4f28344 commit 9c7022f
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/math/Vec3.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,22 @@ Vec3.prototype.vmul = function(vector, target){
*/
Vec3.prototype.scale = Vec3.prototype.mult;

/**
* Scale a vector and add it to this vector. Save the result in "target". (target = this + vector * scalar)
* @method addScaledVector
* @param {Number} scalar
* @param {Vec3} vector
* @param {Vec3} target The vector to save the result in.
* @return {Vec3}
*/
Vec3.prototype.addScaledVector = function(scalar, vector, target){
target = target || new Vec3();
target.x = this.x + scalar * vector.x;
target.y = this.y + scalar * vector.y;
target.z = this.z + scalar * vector.z;
return target;
};

/**
* Calculate dot product
* @method dot
Expand Down

0 comments on commit 9c7022f

Please sign in to comment.