xxxxxxxxxx
28
// Daniel Shiffman
// https://thecodingtrain.com/CodingChallenges/145-2d-ray-casting.html
// https://youtu.be/TOEi6T2mtHo
// 2D Ray Casting
class Boundary {
constructor(x1, y1, x2, y2) {
this.a = createVector(x1, y1);
this.b = createVector(x2, y2);
}
show() {
stroke(255);
line(this.a.x, this.a.y, this.b.x, this.b.y);
}
get center() {
const
a = this.a.copy(),
b = this.b.copy();
b.sub(a);
b.mult(0.5);
b.add(a);
return b;
}
}