Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added vec2.copy

  • Loading branch information...
commit e9e06179ec56ba4d81afb74f2259b907620ee350 1 parent c4c1cf8
Brandon Jones authored
View
3  Gemfile
@@ -6,9 +6,6 @@ gem 'rake'
# https://github.com/pivotal/jasmine-gem
gem 'jasmine'
-# https://github.com/cowboyd/therubyracer
-gem 'therubyracer'
-
# https://github.com/sstephenson/sprockets
gem 'sprockets'
View
4 Gemfile.lock
@@ -16,7 +16,6 @@ GEM
selenium-webdriver (>= 0.1.3)
jasmine-core (1.2.0)
json (1.7.4)
- libv8 (3.3.10.4)
libwebsocket (0.1.5)
addressable
multi_json (1.3.6)
@@ -41,8 +40,6 @@ GEM
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
- therubyracer (0.10.2)
- libv8 (~> 3.3.10)
thor (0.14.6)
tilt (1.3.3)
uglifier (1.2.7)
@@ -57,6 +54,5 @@ DEPENDENCIES
json
rake
sprockets
- therubyracer
thor
uglifier
View
2  dist/gl-matrix-min.js
@@ -20,4 +20,4 @@
* 3. This notice may not be removed or altered from any source
* distribution.
*/
-(function(){"use strict";var e={};typeof exports=="undefined"?e.exports=window:e.exports=exports,function(e){(function(){var t={};t.create=function(){return new Float32Array(2)},t.clone=function(e){var t=new Float32Array(2);return t[0]=e[0],t[1]=e[1],t},t.fromValues=function(e,t){var n=new Float32Array(2);return n[0]=e,n[1]=t,n},t.add=function(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e},t.sub=t.subtract=function(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e},t.mul=t.multiply=function(e,t,n){return e[0]=t[0]*n[0],e[1]=t[1]*n[1],e},t.div=t.divide=function(e,t,n){return e[0]=t[0]/n[0],e[1]=t[1]/n[1],e},t.scale=function(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e},t.dist=t.distance=function(e,t){var n=t[0]-e[0],r=t[1]-e[1];return Math.sqrt(n*n+r*r)},t.sqrDist=t.squaredDistance=function(e,t){var n=t[0]-e[0],r=t[1]-e[1];return n*n+r*r},t.len=t.length=function(e){var t=e[0],n=e[1];return Math.sqrt(t*t+n*n)},t.sqrLen=t.squaredLength=function(e){var t=e[0],n=e[1];return t*t+n*n},t.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e},t.normalize=function(e,t){var n=t[0]*t[0]+t[1]*t[1];return n>0&&(n=Math.sqrt(n),e[0]=t[0]/n,e[1]=t[1]/n),e},t.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]},t.cross=function(e,t,n){var r=t[0]*n[1]-t[1]*n[0];return e[0]=e[1]=0,e[2]=r,e},t.lerp=function(e,t,n,r){var i=t[0],s=t[1];return e[0]=i+r*(n[0]-i),e[1]=s+r*(n[1]-s),e},t.str=function(e){return"vec2("+e[0]+", "+e[1]+")"},e.vec2=t})()}(e.exports)})();
+(function(){"use strict";var e={};typeof exports=="undefined"?e.exports=window:e.exports=exports,function(e){(function(){var t={};t.create=function(){return new Float32Array(2)},t.clone=function(e){var t=new Float32Array(2);return t[0]=e[0],t[1]=e[1],t},t.fromValues=function(e,t){var n=new Float32Array(2);return n[0]=e,n[1]=t,n},t.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e},t.add=function(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e},t.sub=t.subtract=function(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e},t.mul=t.multiply=function(e,t,n){return e[0]=t[0]*n[0],e[1]=t[1]*n[1],e},t.div=t.divide=function(e,t,n){return e[0]=t[0]/n[0],e[1]=t[1]/n[1],e},t.scale=function(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e},t.dist=t.distance=function(e,t){var n=t[0]-e[0],r=t[1]-e[1];return Math.sqrt(n*n+r*r)},t.sqrDist=t.squaredDistance=function(e,t){var n=t[0]-e[0],r=t[1]-e[1];return n*n+r*r},t.len=t.length=function(e){var t=e[0],n=e[1];return Math.sqrt(t*t+n*n)},t.sqrLen=t.squaredLength=function(e){var t=e[0],n=e[1];return t*t+n*n},t.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e},t.normalize=function(e,t){var n=t[0]*t[0]+t[1]*t[1];return n>0&&(n=Math.sqrt(n),e[0]=t[0]/n,e[1]=t[1]/n),e},t.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]},t.cross=function(e,t,n){var r=t[0]*n[1]-t[1]*n[0];return e[0]=e[1]=0,e[2]=r,e},t.lerp=function(e,t,n,r){var i=t[0],s=t[1];return e[0]=i+r*(n[0]-i),e[1]=s+r*(n[1]-s),e},t.str=function(e){return"vec2("+e[0]+", "+e[1]+")"},e.vec2=t})()}(e.exports)})();
View
13 dist/gl-matrix.js
@@ -103,6 +103,19 @@
};
/**
+ * Copy the values from on vec2 to another
+ *
+ * @param {vec2} out the receiving vector
+ * @param {vec2} a the source vector
+ * @returns {vec2} out
+ */
+ vec2.copy = function(out, a) {
+ out[0] = a[0];
+ out[1] = a[1];
+ return out;
+ };
+
+ /**
* Adds two vec2's
*
* @param {vec2} out the receiving vector
View
6 spec/gl-matrix/vec2-spec.js
@@ -40,6 +40,12 @@ describe("vec2", function() {
beforeEach(function() { result = vec2.fromValues(1, 2); });
it("should return a 2 element array initialized to the values passed", function() { expect(result).toBeEqualish([1, 2]); });
});
+
+ describe("copy", function() {
+ beforeEach(function() { result = vec2.copy(out, vecA); });
+ it("should place values into out", function() { expect(out).toBeEqualish([1, 2]); });
+ it("should return out", function() { expect(result).toBe(out); });
+ });
describe("add", function() {
describe("with a separate output vector", function() {
View
13 src/gl-matrix/vec2.js
@@ -65,6 +65,19 @@
};
/**
+ * Copy the values from on vec2 to another
+ *
+ * @param {vec2} out the receiving vector
+ * @param {vec2} a the source vector
+ * @returns {vec2} out
+ */
+ vec2.copy = function(out, a) {
+ out[0] = a[0];
+ out[1] = a[1];
+ return out;
+ };
+
+ /**
* Adds two vec2's
*
* @param {vec2} out the receiving vector
Please sign in to comment.
Something went wrong with that request. Please try again.