VisHull

Computes the visible region from a point for a given environment represented by a collection of line segments

Example Image

Source:
See:
Example
let walls = [
     [[0, 0], [100, 0]],
     [[100, 0], [100, 100]],
     [[100, 100], [0, 100]],
     [[0, 100], [0, 0]]
];
let lines = VisHull.create(walls, 5, 5);

let start = {x: lines[0][0], y: lines[0][1]};

ctx.beginPath()
ctx.moveTo(start.x, start.y)
for (var i = 1; i < lines.length; ++i) {
    ctx.lineTo(lines[i][0], lines[i][1]);
}
ctx.lineTo(start.x, start.y);
ctx.closePath();
ctx.fill();

Methods

(static) create(segments, cx, cy) → {Array}

Source:

create a visual hull

Parameters:
Name Type Description
segments Array

array of points, the maximum range for each point is -100000000 to 100000000

cx Number

x coordinate of the center

cy Number

y coordinate of the center

Returns:

Polygon points that describe the projected hull, in the form [[x1, y1], [x2, y2], ...]

Type
Array