Permalink
Browse files

No more node stuff - only Rack

  • Loading branch information...
rbgrouleff committed Jun 20, 2012
1 parent dec9b47 commit b41df14e024f4c876d5377fa74c41c49164ec3a2
View
@@ -10,9 +10,9 @@ Internet Explorer >=10.0.
It is heavily inspired from http://www.arachnoid.com/ruby/gravity/index.html -
which is also where I have the planetary data from.
-If you want to run it, just clone this repo, run `npm install` in the
-dir, run the server with `coffee server` and point your browser to
-http://localhost:3000/index.html
+If you want to run it, just clone this repo, run `bundle install` in the
+dir, run the server with `rackup` and point your browser to
+http://localhost:9292/
#License
View
@@ -1,55 +0,0 @@
-(function() {
- var Body;
-
- module.exports = Body = (function() {
-
- Body.G = 6.6742e-11;
-
- function Body(name, radius, mass, position, velocity) {
- this.name = name;
- this.radius = radius;
- this.mass = mass;
- this.position = position;
- this.velocity = velocity;
- }
-
- Body.prototype.exertPullOn = function(otherBody, dt) {
- var radius;
- if (otherBody === this) return;
- radius = otherBody.position.sub(this.position);
- return otherBody.updateVelocity(radius, this.mass, dt);
- };
-
- Body.prototype.updateVelocity = function(r, mass, dt) {
- var acceleration, hypot, sumOfSquares;
- sumOfSquares = r.sumOfSquares();
- hypot = Math.sqrt(sumOfSquares);
- acceleration = -Body.G * mass / sumOfSquares;
- return this.velocity = this.velocity.add(r.div(hypot).mult(acceleration * dt));
- };
-
- Body.prototype.calculateGravitationalPull = function(otherBody, dt) {
- var acceleration, hyp, radius, radiusSquared;
- if (otherBody !== this) {
- radius = this.position.sub(otherBody.position);
- radiusSquared = radius.sumOfSquares();
- hyp = Math.sqrt(radiusSquared);
- acceleration = -Body.G * otherBody.mass / radiusSquared;
- return this.velocity = this.velocity.add(radius.div(hyp).mult(acceleration * dt));
- }
- };
-
- Body.prototype.move = function(dt) {
- this.oldPosition = this.position;
- return this.position = this.position.add(this.velocity.mult(dt));
- };
-
- Body.prototype.distanceToCenter = function() {
- return Math.sqrt(this.position.sumOfSquares());
- };
-
- return Body;
-
- })();
-
-}).call(this);
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -1,55 +0,0 @@
-(function() {
- var Vector;
-
- module.exports = Vector = (function() {
-
- function Vector(x, y) {
- this.x = x;
- this.y = y;
- }
-
- Vector.prototype.mult = function(v) {
- if (this.constructor === v.constructor) {
- return new Vector(this.x * v.x, this.y * v.y);
- } else {
- return new Vector(this.x * v, this.y * v);
- }
- };
-
- Vector.prototype.div = function(v) {
- if (this.constructor === v.constructor) {
- return new Vector(this.x / v.x, this.y / v.y);
- } else {
- return new Vector(this.x / v, this.y / v);
- }
- };
-
- Vector.prototype.add = function(v) {
- return new Vector(this.x + v.x, this.y + v.y);
- };
-
- Vector.prototype.sub = function(v) {
- return new Vector(this.x - v.x, this.y - v.y);
- };
-
- Vector.prototype.sumOfSquares = function() {
- return this.x * this.x + this.y * this.y;
- };
-
- Vector.prototype.eq = function(v) {
- if (v) {
- return this.x === v.x && this.y === v.y;
- } else {
- return false;
- }
- };
-
- Vector.prototype.toString = function() {
- return "(" + this.x + ", " + this.y + ")";
- };
-
- return Vector;
-
- })();
-
-}).call(this);
View
@@ -1,5 +0,0 @@
-{
- "name": "gravity",
- "version": "0.0.1",
- "main": "./lib/main.js"
-}
Oops, something went wrong.

0 comments on commit b41df14

Please sign in to comment.