plexsoup said: Stephen, any chance of adding an intersect (or raycast) function to your vector math library? I need to check to see if the vector defined by [currentLocation, lastLightCrumbLocation] instersects with any nearby paths on the dynamic lighting layer. If they intersect, then I know light is occluded, so I should drop a new LightCrumb. Actually, I do have some segment intersection algorithms available in my Path Math script, including classes for shapes and testing intersections between them in the latest version (not yet merged into the upstream repo): <a href="https://github.com/Cazra/roll20-api-scripts/blob/t" rel="nofollow">https://github.com/Cazra/roll20-api-scripts/blob/t</a>... All this is done by using Path Math to convert paths into a series of segments, then testing intersections between those segments using // The segments' points should be homogeneous coordinates. E.g. [x,y,1]
let intersection = PathMath.segmentIntersection(segment1, segment2);
let pointOfIntersection = intersection[0];
let segment1IntersectionScalar = intersection[1]; // This will be in the range of [0,1].
let segment2IntersectionScalar = intersection[2]; // This will also be in the range of [0,1].
// intersection will be undefined if segment1 and segment2 are parallel or don't intersect. Path Math currently doesn't have ray casting, but it would be trivial to use code from PathMath.segmentIntersection to implement that. Path Math has the additional requirement of Matrix Math. plexsoup said: @Stephen L: That sounds pretty good! I see you even have a distance function. So, forgive my ignorance... How do I include functions from another script? Also, how do I make sure people have both scripts installed? To include functions from another script, just use whatever global variables they expose. For example, to use Vector Math, just call something like let v = VecMath.sub(pt2, pt1); To make sure that other people have both scripts installed, you can set up Vector Math as a dependency for your script in its script.json file if you are putting it in the Roll20 repository. When the script is installed through the One-Click installer, it will automatically install those dependencies. If you plan on releasing this as a gist, just add a note to users to install the dependency scripts.