summaryrefslogtreecommitdiff
path: root/assets/javascripts/math/point.js
diff options
context:
space:
mode:
Diffstat (limited to 'assets/javascripts/math/point.js')
-rw-r--r--assets/javascripts/math/point.js9
1 files changed, 9 insertions, 0 deletions
diff --git a/assets/javascripts/math/point.js b/assets/javascripts/math/point.js
index 354be00..5a5d0db 100644
--- a/assets/javascripts/math/point.js
+++ b/assets/javascripts/math/point.js
@@ -5,6 +5,15 @@
this.a = a
this.b = b
}
+
+ point.prototype.distanceTo = function(p){
+ return Math.sqrt(this.dot(p))
+ }
+ point.prototype.dot = function(p){
+ return Math.pow(this.a - p.a, 2) + Math.pow(this.b - p.b, 2)
+ }
+
+
point.prototype.magnitude = function(){
return this.b-this.a
}