@RIL wrote:
I’m comparing two 3d Vectors using Dot Product, but I keep getting strange results. I compare the yellow Vector3d (n), a face normal, with the “cube-direction” Vector3d a. The Box is planar (XY) and therefore it regards only the Planar (XY) angle of vector a. But when I try calculate the angle between the two vectors I don’t get expected results(n is not parallel to n (0 degree) where it should be parallel):
In the code below the variable
m_dirToDeleteis the vector “a” pictured above :if ( m_dirToDelete.Length > 0 ) { // Test the face normal direction angle against the m_dirToDelete direction. // Remove the MeshFace if less than x° degree tolerance (+/- 1°). // Vector3d n = normal; Vector3d a = m_dirToDelete; // Project both vectors down to XY plane (planarize) // a.Z = 0; n.Z = 0; // Get the Dot product // a.Unitize(); n.Unitize(); double dot = a.X * n.X + a.Y * n.Y; // + a.Z * n.Z; 0-values are meaningless. double deg = Math.Acos(dot) * (180/Math.PI); // Record MeshFace index, if the vectors are within angle tolerance of each other // if ( deg < 1 && deg > -1 ) { //face index to be deleted FaceIndiciesToDelete.Add(i); } }So, something is wrong with the math, since I know that there are several yellow faces (n) having the same (planar XY) direction as the red arrow (a).
What am I doing wrong?
// Rolf
Posts: 4
Participants: 3
