Segment has an isZeroLength method - would it make sense to add the same for Vector?
Of couse I can do vec.length === 0, but this involves an expensive Math.sqrt.
I can do vec.dot(vec) === 0 to avoid the sqrt, but this somewhat less readable.
Alternatively, maybe we could have a lengthSquared method - that would also serve cases where vectors need to be compared by length, and the overhead of the sqrt is not necessary
Segment has an
isZeroLength
method - would it make sense to add the same forVector
?Of couse I can do
vec.length === 0
, but this involves an expensiveMath.sqrt
. I can dovec.dot(vec) === 0
to avoid the sqrt, but this somewhat less readable.