When you try to normalize [0,0,0] vector you will get weird result because of division by zero. That can cause for example node disappearing when fly straight animator from potin A to point A is added to it.
Here's fixed normalize() methods for vector2d and vector3d classes.
Code: Select all
// vector2d.h
vector2d<T>& normalize()
{
T inv;
if(getLength() != 0.0) inv = (T)(1.0 / getLength());
else inv = (T)0.0;
X *= inv;
Y *= inv;
return *this;
}
// vector3d.h
vector3d<T>& normalize()
{
T inv;
if(getLength() != 0.0) inv = (T)(1.0 / getLength());
else inv = (T)0.0;
X *= inv;
Y *= inv;
Z *= inv;
return *this;
}