Clockwise angle between two Vector3

Started by
11 comments, last by bdubreuil 6 years ago

So you have two normals of adjacent convex polygons. Let's call the barycenters of the polygons A and B, and the corresponding normals vA and vB. Now compute n = cross_product(vA,vB). Now compute the [unsigned] angle between vA and vB and multiply the result by the sign of the determinant of the matrix whose columns are vA, vB and n. That's either the answer you want, or minus the answer you want. I can't be bother to figure out which, so just try it. :)

 

Advertisement
5 minutes ago, alvaro said:

So you have two normals of adjacent convex polygons. Let's call the barycenters of the polygons A and B, and the corresponding normals vA and vB. Now compute n = cross_product(vA,vB). Now compute the [unsigned] angle between vA and vB and multiply the result by the sign of the determinant of the matrix whose columns are vA, vB and n. That's either the answer you want, or minus the answer you want. I can't be bother to figure out which, so just try it.

 


Vector3f directionReference = m_edgeVertexLeft.subtract(m_edgeVertexRight).normalizeLocal();
Vector3f meshNormal = m_mesh.getPolygon().getNormal();
Vector3f otherMeshNormal = m_otherMesh.getPolygon().getNormal();

float det = directionReference.dot(meshNormal.cross(otherMeshNormal));
float angle = (float) Math.atan2(det, meshNormal.dot(otherMeshNormal));

It computes what I actually want : a negative angle for upwards inclinations and a positive angle for a downwards inclination.

Hide yo cheese! Hide yo wife!

This topic is closed to new replies.

Advertisement