diff options
Diffstat (limited to 'public/assets/test/intersect3.html')
| -rw-r--r-- | public/assets/test/intersect3.html | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/public/assets/test/intersect3.html b/public/assets/test/intersect3.html index ed81346..5440a76 100644 --- a/public/assets/test/intersect3.html +++ b/public/assets/test/intersect3.html @@ -217,8 +217,9 @@ function draw (time) { end_of_ray.a += len * cos(aw) end_of_ray.b += len * sin(aw) -// end_of_ray.a = clamp(end_of_ray.a, wall_vec.x.a, wall_vec.y.a) -// end_of_ray.b = clamp(end_of_ray.b, wall_vec.x.b, wall_vec.y.b) + wall_vec.normalize() + end_of_ray.a = clamp(end_of_ray.a, wall_vec.x.a, wall_vec.y.a) + end_of_ray.b = clamp(end_of_ray.b, wall_vec.x.b, wall_vec.y.b) drawPoint(end_of_ray) drawLine(closest_intersect2, end_of_ray, "#00f") @@ -295,7 +296,19 @@ cursor.extend_ends = function(n){ clone.y.b += n*sin(a) return clone } - +wall_vec.normalize = function(){ + var carry + if (this.x.a > this.y.a) { + carry = this.x.a + this.x.a = this.y.a + this.y.a = carry + } + if (this.x.b > this.y.b) { + carry = this.x.b + this.x.b = this.y.b + this.y.b = carry + } +} function animate(time){ requestAnimationFrame(animate) draw(time) |
