excaliburjs / Excalibur

🎮 Your friendly TypeScript 2D game engine for the web 🗡️
https://excaliburjs.com
BSD 2-Clause "Simplified" License
1.77k stars 189 forks source link

Unexpected result of .normalize() on already Zero vector #3171

Closed eonarheim closed 1 month ago

eonarheim commented 1 month ago

Steps to Reproduce

Attempt to normalize a vector of length zero

image

Other prior art is that Godot/Unity/Unreal all return a zero vector

Expected Result

Return a vector copy that is also zero

Actual Result

Arbitrary direction is returned

Environment

Latest

Current Workaround

Check for zero vectors before normalizing