summaryrefslogtreecommitdiff
path: root/assets/javascripts/rectangles/models/vec2.js
diff options
context:
space:
mode:
Diffstat (limited to 'assets/javascripts/rectangles/models/vec2.js')
-rw-r--r--assets/javascripts/rectangles/models/vec2.js9
1 files changed, 9 insertions, 0 deletions
diff --git a/assets/javascripts/rectangles/models/vec2.js b/assets/javascripts/rectangles/models/vec2.js
index 3105fec..7307fca 100644
--- a/assets/javascripts/rectangles/models/vec2.js
+++ b/assets/javascripts/rectangles/models/vec2.js
@@ -54,6 +54,15 @@ vec2.normalize = function(){
vec2.prototype.contains = function(n){
return this.a <= n && n <= this.b
}
+vec2.prototype.containsDisc = function(n,r){
+ return this.a <= n-r && n+r <= this.b
+}
+vec2.prototype.clamp = function(n){
+ return clamp(n, this.a, this.b)
+}
+vec2.prototype.clampDisc = function(n,r){
+ return clamp(n, this.a+r, this.b-r)
+}
vec2.prototype.intersects = function(v){
if (this.a < v.a) {
return (v.a < this.b && this.b <= v.b) || (this.a < v.b && v.b <= this.b)