Proposals:
Have an out parameter somewhere in the argument list that gets the intersection point copied into it. e.g.,
function segseg (out, pos1, pos2, pos3, pos4) { ... } // returns boolean
I'd also propose using gl-matrix's vec2 convention (an array of 2 numbers): [ x, y ]
benefits:
- not generating a new array object every time this function is invoked will result in less garbage collection. (not a big deal for a few calls to this function, but for a game/simulation which can call this thousands of times per second this can make a big difference
- making the return object of
segseg always a boolean rather than a mixed type makes it easier for the vm to optimize
- this format of having an
out field first matches very closely what gl-matrix does, moving us torwards slightly better interoperability
- easier to read
cons:
- forms an opinion on vec2/point representation on behalf of the user (the
[ x, y ] vs { x, y } data representation debate)
- breaking API change requiring major version bump
thoughts?
Proposals:
Have an
outparameter somewhere in the argument list that gets the intersection point copied into it. e.g.,I'd also propose using
gl-matrix's vec2 convention (an array of 2 numbers):[ x, y ]benefits:
segsegalways a boolean rather than a mixed type makes it easier for the vm to optimizeoutfield first matches very closely whatgl-matrixdoes, moving us torwards slightly better interoperabilitycons:
[ x, y ]vs{ x, y }data representation debate)thoughts?