Conversation
Co-authored-by: Augustin Mauroy <97875033+AugustinMauroy@users.noreply.github.com>
| const expected = 0.9553166181 | ||
| assert.strictEqual(angle1, angle2) | ||
| assert.strictEqual(Math.round(angle1 * 100000), Math.round(expected * 100000)) | ||
| }) |
There was a problem hiding this comment.
add a test case with both norm is 0 it's may create something strange
There was a problem hiding this comment.
in importation you need to cache norm first then check if not 0 if both 0 need to return 0
IMO it's the cleanest way to fix that
There was a problem hiding this comment.
No, it needs to return NaN, because this.dot(other) / (this.norm() * other.norm()) in this case is 0 / 0, which is indeterminate, not zero.
In practice, getting NaN signifies that the angle has no meaning, because the vectors are degenerate and don't actually have a direction. This case must be handled by the user, not here.
It actually happens also if only one of the vectors is null.
|
Not sure if you are waiting for me to merge, but I am not allowed to do it. |
No description provided.