Vector3d Normalize
843799Dec 21 2001 — edited Jan 2 2002Why does the normalize() method of Vector3d sometimes return a vector 0.0, -1.0, 0.0 and sometimes 0.0, -0.999999999..., 0.0?
The code is where v1 and v2 lie in the global cartesian xz plane and are perpendicular to each other.
Vector3d v1 = new Vector3d();
Vector3d v2 = new Vector3d();
Vector3d v3 = new Vector3d();
v1.set(somex,somey,somez);
v2.set(someotherx,someothery,someotherz);
v3.cross(v1,v2);
v3.normalize();
My program test for a cross product vector parallel to one of the global axis by checking for 1.0 as a vector component. But fails occasionally because its not exactly 1.0.
Similar behaviour for some vectors in the other global planes.