Browse Source

Add dot_product function for vector calculations and such

master
Sven Slootweg 9 years ago
parent
commit
5264bb1a9d
  1. 15
      core.js

15
core.js

@ -178,7 +178,7 @@ Function.prototype.inheritsFrom = function(parentObject)
this.Add = function()
{
var new_point = new RadiumEngine.Point(this.x, this.y);
console.log(arguments);
for (i in arguments)
{
new_point.x += arguments[i].x;
@ -208,4 +208,17 @@ Function.prototype.inheritsFrom = function(parentObject)
var yL = y1 - y2;
return Math.sqrt((xL * xL) + (yL * yL));
}
RadiumEngine.dot_product = function(a, b)
{
var n = 0;
var lim = Math.min(a.length, b.length);
for (var i = 0; i < lim; i++)
{
n += a[i] * b[i];
}
return n;
}
}
Loading…
Cancel
Save