Ren
Ren

Reputation: 463

How to determine if an edge is concave or convex in 3d?

I'm working with the library OpenMesh in C++. I have a function which should return whether or not an edge is concave or convex.

bool isConcave(HalfedgeHandle initial, Mesh & mesh){
    FaceHandle face1 = mesh.face_handle(initial);
    FaceHandle face2 = mesh.face_handle(mesh.opposite_halfedge_handle(initial));
    long double angle = angleBetweenVectors(mesh.calc_face_normal(face1), mesh.calc_face_normal(face2));
    if (angle >= (M_PI/2)){
        cout << "Convex " << (angle * RADIANS_TO_DEGREES) << "\n";
        return false;}
    else{
        cout << "Concave " << (angle * RADIANS_TO_DEGREES) << "\n";
        return true;}}

where the function angleBetweenVectors(Vec3f, Vec3f) is implemented as

return acosl(dot(vec1, vec2) / (vec1.norm() * vec2.norm()));

But when I run this on various edges of the cube built in the tutorial on OpenMesh, I have output of "Concave 0" and "Convex 90," when all the edges should be convex 90. Why is my output incorrect?

Upvotes: 1

Views: 1531

Answers (1)

Ren
Ren

Reputation: 463

Well, in case anybody else wants to know, since I realized the issue...

The cube is a triangular mesh. Therefore each face of the cube is actually split into two triangular faces. Thus, some faces are technically parallel, giving an angle between these faces as 0 degrees.

Upvotes: 1

Related Questions