This site is currently read-only as we are migrating to Oracle Forums for an improved community experience. You will not be able to initiate activity until January 31st, when you will be able to use this site as normal.

    Forum Stats

  • 3,890,899 Users
  • 2,269,649 Discussions
  • 7,916,821 Comments

Discussions

Vector3d Normalize

843799
843799 Member Posts: 49,999
edited Jan 2, 2002 4:57AM in Java 3D
Why 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.


Comments

This discussion has been closed.