Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Vector3d Normalize

843799Dec 21 2001 — edited Jan 2 2002
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

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Jan 30 2002
Added on Dec 21 2001
1 comment
142 views