From c92a9d3f963401b999f661dde190a739ebbeafde Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Mon, 24 Dec 2012 20:53:07 -0800 Subject: [PATCH] Fix a bug in project() It was kind of sheer luck that any extrudes worked before this fix. Also, add rotation to torus_by_extrude, which was an easy way to reproduce this. --- nt3d.js | 2 +- torus_by_extrude.html | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/nt3d.js b/nt3d.js index c69c185..fd57824 100644 --- a/nt3d.js +++ b/nt3d.js @@ -211,7 +211,7 @@ nt3d = { }, project: function(a, b) { // Project b onto a var a_magnitude = this.magnitude(a); - return this.scale(a, this.dot(a, b) / a_magnitude * a_magnitude); + return this.scale(a, this.dot(a, b) / (a_magnitude * a_magnitude)); }, project_to_orthogonal: function(a, b) { // The nearest thing to b that is orthogonal to a diff --git a/torus_by_extrude.html b/torus_by_extrude.html index 4655519..10ae92e 100644 --- a/torus_by_extrude.html +++ b/torus_by_extrude.html @@ -3,8 +3,9 @@ Torus by extrude -- 2.44.1